获得mp3隐藏信息时英文正确中文会出错

jzywh 2004-01-04 12:02:12
获得mp3隐藏信息时英文正确中文会出错

程序如下

Public Artist As String
Public Album As String
Public Title As String
Public Year As String
Public Comments As String
Public txtAll As String
Public Genre As Integer

Public Function GetMp3Tag(FName As String)
Dim strArtist As String
Dim strAlbum As String
Dim strTitle As String
Dim strYear As String
Dim strComments As String
Dim strAll As String
Dim strGenre As Integer

If FName = "" Then Exit Function

If Dir(FName) = "" Then Exit Function

Dim FileNum As Integer

FileNum = FreeFile

Dim strInput As String

Open FName For Binary Access Read As FileNum

If LOF(FileNum) < 128 Then
Close FileNum
Exit Function
End If

Seek FileNum, LOF(FileNum) - 127
strInput = Space(3)
Get FileNum, , strInput


If strInput <> "TAG" Then
Close FileNum
GoTo Done:
End If

strInput = Space(30)
Get FileNum, , strInput
strTitle = strInput

strInput = Space(30)
Get FileNum, , strInput
strArtist = strInput

strInput = Space(30)
Get FileNum, , strInput
strAlbum = strInput

strInput = Space(4)
Get FileNum, , strInput
strYear = strInput

strInput = Space(31)
Get FileNum, , strInput
strComments = strInput

strInput = Space(1)
Get FileNum, , strInput
strGenre = Asc(strInput)


Done:
Title = strTitle
Artist = strArtist
Album = strAlbum
Year = strYear
Comments = strComments
If Genre < 0 Or Genre > 254 Then Genre = 12
Genre = CInt(strGenre)

Close FileNum

End Function
Public Function GetMp3Tag1(FName As String) As String

Dim strAll As String

If FName = "" Then Exit Function

If Dir(FName) = "" Then Exit Function

Dim FileNum As Integer

FileNum = FreeFile

Dim strInput As String

Open FName For Binary Access Read As FileNum

If LOF(FileNum) < 128 Then
Close FileNum
Exit Function
End If

Seek FileNum, LOF(FileNum) - 127
strInput = Space(3)
Get FileNum, , strInput


If strInput <> "TAG" Then
Close FileNum
GoTo Done:
End If

strInput = Space(128)
Get FileNum, , strInput
strAll = strInput

GetMp3Tag1 = strAll

Done:

txtAll = strAll

Close FileNum

End Function
Public Function output(strArg As String)
Set fs = CreateObject("Scripting.FileSystemObject")
Set ofile = fs.createtextfile("C:\alert.txt")
ofile.writeline strArg
ofile.Close
End Function


Private Sub Command1_click()
CommonDialog1.InitDir = "e:\music"
CommonDialog1.Filter = "mp3 (*.mp3)|*.mp3"
CommonDialog1.ShowOpen
Text6.Text = CommonDialog1.FileName
GetMp3Tag (CommonDialog1.FileName)
Text1.Text = Title
Text2.Text = Artist
Text3.Text = Album
Text4.Text = Year
Text5.Text = Comments
output (GetMp3Tag1(CommonDialog1.FileName))
Text7.Text = GetMp3Tag1(CommonDialog1.FileName) & "xp"
End Sub


如果隐藏信息是E文,那就显示正确

如果是中文就会错位!


请问如何解决这个问题?





...全文
16 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lk_cool 2004-01-04
现收藏,慢慢看,
可能会明白
回复
up 先

具体的没有研究过,不过我到遇到过用不同的winmap面板播mp3文件是,如果文件名是中文的时候,是会有乱码显示,但是有时换了面板,就会正常.我也纳闷过........
回复
jzywh 2004-01-04
OK!

你是牛人,十分感谢你!

分全给你!
回复
shongshan 2004-01-04
在这是替换:
'Seek FileNum, LOF(FileNum) - 124
ReDim strInput(29)
Get FileNum, , strInput
Title = StrConv(strInput, vbUnicode)
回复
jzywh 2004-01-04
to shongshan(松山学院)

ReDim strInput(29) 是在哪里用,语法也有问题呀!


请详解,谢谢!
回复
shongshan 2004-01-04
http://expert.csdn.net/Expert/topic/2625/2625052.xml?temp=1.467532E-02
回复
shongshan 2004-01-04
定义字节数组:(可以解决你的问题)
Dim strInput() As Byte

ReDim strInput(29)
回复
发帖
VB基础类
创建于2007-09-28

7479

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2004-01-04 12:02
社区公告
暂无公告