mcm铆钉双肩包真假区别:如何使用这个过程 VB

来源:百度文库 编辑:高校问答 时间:2024/05/12 12:23:41
Public Type Mp3tag
Artist As String 'Artist 存储歌手信息
Album As String 'Album 存储唱片专辑信息
Title As String 'Title 存储标题信息
sYear As String 'Year 存储年代信息
Comments As String 'Comments 存储备注信息
Genre As Integer 'Genre 存储音乐风格序列
End Type

Public Function GetMp3Tag(FName As String) As Mp3tag
Dim Artist As String
Dim Album As String
Dim Title As String
Dim Year As String
Dim Comments As String
Dim Genre As Integer
If FName = "" Then Exit Function
If Dir(FName) = "" Then Exit Function
Dim FileNum As Integer
FileNum = FreeFile '得到一个自由的文件号
Dim strInput() As Byte
Open FName For Binary Access Read As FileNum '以二进制形式打开文件
If LOF(FileNum) < 128 Then
Close FileNum
Exit Function
End If
Seek FileNum, LOF(FileNum) - 127 '把文件指针移动到MP3信息处
ReDim strInput(2)
Get FileNum, , strInput
If StrConv(strInput, vbUnicode) <> "TAG" Then '如果没有发现信息标识,就关闭文件
Close FileNum
GoTo Done
End If
On Error Resume Next
ReDim strInput(29)
Get FileNum, , strInput
Title = StrConv(strInput, vbUnicode)
Title = Left$(Title, InStr(1, Title, vbNullChar) - 1)
Get FileNum, , strInput
Artist = StrConv(strInput, vbUnicode)
Artist = Left$(Artist, InStr(1, Artist, vbNullChar) - 1)
Get FileNum, , strInput
Album = StrConv(strInput, vbUnicode)
Album = Left$(Album, InStr(1, Album, vbNullChar) - 1)
ReDim strInput(3)
Get FileNum, , strInput
sYear = StrConv(strInput, vbUnicode)
sYear = Left$(Year, InStr(1, Year, vbNullChar) - 1)
ReDim strInput(29)
Get FileNum, , strInput
Comments = StrConv(strInput, vbUnicode)
Comments = Left$(Comments, InStr(1, Comments, vbNullChar) - 1)
ReDim strInput(0)
Get FileNum, , strInput
Genre = Asc(strInput)
Done:
GetMp3Tag.Title = Title
GetMp3Tag.Artist = Artist
GetMp3Tag.Album = Album
GetMp3Tag.sYear = sYear
GetMp3Tag.Comments = Comments
If Genre < 0 Or Genre > 254 Then Genre = 12
GetMp3Tag.Genre = CInt(Genre)
Close FileNum
End Function

1、把上述代码复制,然后在自己的代码中设计需要被打开的“*.MP3”文件名,需要是全路径的,比如:MyStr = "C:\Music\甜蜜蜜.Mp3"

2、自己定义一个变量,例如:Dim MyMp3Tag As Mp3Tag

3、然后调用这个子函数就可以了。格式是:MyMp3Tag = GetMp3Tag(MyStr)

4、输出结果(如果文件正常),MyStr就是一个包含“存储歌手信息、存储唱片专辑信息、存储标题信息、存储年代信息、存储备注信息、存储音乐风格序列”的信息。如果想得到“存储歌手信息”,可以使用MyString = MyMp3Tag.Artist