首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

C#代码帮忙翻译成Delphi7代码,该怎么处理

2013-01-04 
C#代码帮忙翻译成Delphi7代码IntPtr p BASS_ChannelGetTags(stream, BASS_TAG_ID3)// check, if ID3v1s

C#代码帮忙翻译成Delphi7代码


IntPtr p = BASS_ChannelGetTags(stream, BASS_TAG_ID3);

// check, if ID3v1
string id = Marshal.PtrToStringAnsi(p, 3);
if (id != "TAG")
    return false;

// song title (comes after 'TAG')...
p = new IntPtr((byte*)p.ToPointer() + 3);
string title = Marshal.PtrToStringAnsi(p).TrimEnd('\0');
int idx = title.IndexOf('\0');
if (idx > 0)
    title = title.Substring(0, idx);
// artist...
p = new IntPtr((byte*)p.ToPointer() + 30);
string artist = Marshal.PtrToStringAnsi(p, 30).TrimEnd('\0');
idx = artist.IndexOf('\0');
if (idx > 0)
    artist = artist.Substring(0, idx);
// album...
p = new IntPtr((byte*)p.ToPointer() + 30);
string album = Marshal.PtrToStringAnsi(p, 30).TrimEnd('\0');
idx = album.IndexOf('\0');
if (idx > 0)
    album = album.Substring(0, idx);
// year...
p = new IntPtr((byte*)p.ToPointer() + 30);
string year = Marshal.PtrToStringAnsi(p, 4).TrimEnd('\0');
idx = year.IndexOf('\0');
if (idx > 0)
    year = year.Substring(0, idx);
// comment...
p = new IntPtr((byte*)p.ToPointer() + 4);
string comment = Marshal.PtrToStringAnsi(p, 30).TrimEnd('\0');
idx = comment.IndexOf('\0');
if (idx > 0)
    comment = comment.Substring(0, idx);
// genre-id...
p = new IntPtr((byte*)p.ToPointer() + 30);
int genreId = (int)Marshal.ReadByte(p);

[解决办法]
BASS_ChannelGetTags是个鸟东西

p可以用Pchar代替,剩下的就是处理Pchar或string了

热点排行