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

C#代码帮忙翻译成Delphi7代码解决办法

2012-06-09 
C#代码帮忙翻译成Delphi7代码C# codeIntPtr p BASS_ChannelGetTags(stream, BASS_TAG_ID3)// check, if

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

C# code
IntPtr p = BASS_ChannelGetTags(stream, BASS_TAG_ID3);// check, if ID3v1string 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了

热点排行