《VB.NET》如何hyper v 删除虚拟机MP3的 ID3v1 ID3v2 。求代码。

VB编程、代码、技术问题解决方案
谁知道怎样读取MP3文件中的ID3信息?
方案整理者:ferer1985 &&&&&& 发布时间:
赞助商广告
谁知道怎样读取和写入MP3文件中的ID3(v1、v2)的信息?
用VC写的也可以…&&(还会继续加分)
推荐解决方案
VERSION&1.0&CLASS
&&MultiUse&=&-1&&'True
&&Persistable&=&0&&'NotPersistable
&&DataBindingBehavior&=&0&&'vbNone
&&DataSourceBehavior&&=&0&&'vbNone
&&MTSTransactionMode&&=&0&&'NotAnMTSObject
Attribute&VB_Name&=&&cMP3&
Attribute&VB_GlobalNameSpace&=&False
Attribute&VB_Creatable&=&True
Attribute&VB_PredeclaredId&=&False
Attribute&VB_Exposed&=&False
Attribute&VB_Ext_KEY&=&&SavedWithClassBuilder6&&,&Yes&
Attribute&VB_Ext_KEY&=&&Top_Level&&,&Yes&
Option&Explicit
Public&Enum&ETagType
&&&NoTag&=&0
&&&ID3v1Tag
&&&ID3v2Tag
&&&ID3v1andID3v2Tags
&&&Lyrics3Tag
&&&ID3v1andLyrics3Tags
&&&ID3v2andLyrics3Tags
&&&AllTags&=&7
Public&Enum&EDirStructure
&&&No_Structure&=&0
&&&Artist_Album_Title&=&1
&&&Artist_Title&=&2
&&&Artist_Dash_Title&=&3
&&&Title_Dash_Artist&=&4
Private&Type&udtID3v1Tag
&&id&As&String&*&3
&&Title&As&String&*&30
&&Artist&As&String&*&30
&&Album&As&String&*&30
&&Year&As&String&*&4
&&Comment&As&String&*&30
&&Genre&As&Byte
'local&variable(s)&to&hold&property&values
Private&m_sFileName&As&String
Private&m_sTitle&As&String
Private&m_sArtist&As&String
Private&m_sAlbum&As&String
Private&m_sComment&As&String
Private&m_sYear&As&String
Private&m_Duration&As&Long
Private&m_BitRate&As&Long
Private&m_Frequency&As&Single
Private&m_Genre&As&Long
Private&m_FileSize&As&Long
Private&m_IsVBR&As&Boolean
Private&m_sLyrics&As&String
Private&m_sQuality&As&String
Private&m_sSituation&As&String
Private&m_sMood&As&String
Private&m_sAuthor&As&String
Private&m_sOtherInfo&As&String
Private&m_sImages&As&String
Private&m_sUnknownFields&As&String
Private&m_LastUpdate&As&Double
Private&m_fValidFile&As&Boolean
Private&m_TagType&As&ETagType
Private&m_DirStructure&As&EDirStructure
Private&m_fReadTagOnly&As&Boolean
'private&variables&used&in&more&than&one&procedure
Private&UnknownLyrics3Fields&As&String
Private&HasLyrics3Tag&As&Boolean
Private&LSZ&As&String
Private&Version&As&Byte
Public&Event&WriteComplete()
Public&Event&ReadComplete()
Public&Property&Let&ReadTagOnly(Tag&As&Boolean)
&&&m_fReadTagOnly&=&Tag
End&Property
Public&Property&Get&ValidFile()&As&Boolean
&&&ValidFile&=&m_fValidFile
End&Property
Public&Property&Get&LastUpdate()&As&Double
&&&LastUpdate&=&m_LastUpdate
End&Property
Public&Property&Let&LastUpdate(NewLastUpdate&As&Double)
&&&m_LastUpdate&=&NewLastUpdate
End&Property
Public&Property&Get&Lyrics()&As&String
&&&Lyrics&=&m_sLyrics
End&Property
Public&Property&Let&Lyrics(NewLyrics&As&String)
&&&m_sLyrics&=&NewLyrics
End&Property
Public&Property&Get&Quality()&As&String
&&&Quality&=&m_sQuality
End&Property
Public&Property&Let&Quality(NewQuality&As&String)
&&&m_sQuality&=&NewQuality
End&Property
Public&Property&Get&Situation()&As&String
&&&Situation&=&m_sSituation
End&Property
Public&Property&Let&Situation(NewSituation&As&String)
&&&m_sSituation&=&NewSituation
End&Property
Public&Property&Get&Mood()&As&String
&&&Mood&=&m_sMood
End&Property
Public&Property&Let&Mood(NewMood&As&String)
&&&m_sMood&=&NewMood
End&Property
Public&Property&Get&Author()&As&String
&&&Author&=&m_sAuthor
End&Property
Public&Property&Let&Author(NewAuthor&As&String)
&&&m_sAuthor&=&NewAuthor
End&Property
Public&Property&Get&OtherInfo()&As&String
&&&OtherInfo&=&m_sOtherInfo
End&Property
Public&Property&Let&OtherInfo(NewOtherInfo&As&String)
&&&m_sOtherInfo&=&NewOtherInfo
End&Property
Public&Property&Get&Images()&As&String
&&&Images&=&m_sImages
End&Property
Public&Property&Let&Images(NewImages&As&String)
&&&m_sImages&=&NewImages
End&Property
Public&Property&Get&TagType()&As&ETagType
&&&TagType&=&m_TagType
End&Property
Public&Property&Let&Year(ByVal&NewYear&As&String)
&&&&m_sYear&=&NewYear
End&Property
Public&Property&Get&Year()&As&String
&&&Year&=&m_sYear
End&Property
Public&Property&Get&Frequency()&As&Single
&&&Frequency&=&m_Frequency
End&Property
Public&Property&Get&BitRate()&As&Long
&&&BitRate&=&m_BitRate
End&Property
Public&Property&Get&DurationInSecs()
&&&DurationInSecs&=&m_Duration
End&Property
Public&Property&Get&Time()&As&String
&&&&Time&=&FormatTime(m_Duration)
End&Property
Public&Property&Let&GenreName(ByVal&NewGenreName&As&String)
&&&&i&=&InStr(gsGenres,&NewGenreName&&&Space$(22&-&Len(NewGenreName)))
&&&&If&i&&&0&Then
&&&&&&&m_Genre&=&Int(i&/&22)
&&&&&&m_Genre&=&12
&&&&End&If
End&Property
Public&Property&Get&GenreName()&As&String
&&&&GenreName&=&Trim$(Mid$(gsGenres,&m_Genre&*&22,&22))
End&Property
Public&Property&Let&Genre(ByVal&NewGenreNumber&As&Long)
&&&&If&NewGenreNumber&&&0&Or&NewGenreNumber&&&147&Then&NewGenreNumber&=&12
&&&&m_Genre&=&NewGenreNumber
End&Property
Public&Property&Get&Genre()&As&Long
&&&&Genre&=&m_Genre
End&Property
Public&Property&Let&Comment(ByVal&NewComment&As&String)
&&&&m_sComment&=&NewComment
End&Property
Public&Property&Get&Comment()&As&String
&&&&Comment&=&m_sComment
End&Property
Public&Property&Let&Album(ByVal&NewAlbum&As&String)
&&&&m_sAlbum&=&NewAlbum
End&Property
Public&Property&Get&Album()&As&String
&&&&Album&=&m_sAlbum
End&Property
Public&Property&Let&Artist(ByVal&NewArtist&As&String)
&&&&m_sArtist&=&NewArtist
End&Property
Public&Property&Get&Artist()&As&String
&&&&Artist&=&m_sArtist
End&Property
Public&Property&Let&Title(ByVal&NewTitle&As&String)
&&&&m_sTitle&=&NewTitle
End&Property
Public&Property&Get&Title()&As&String
&&&&Title&=&m_sTitle
End&Property
Public&Property&Let&FileName(ByVal&FileToRead&As&String)
&&&m_sFileName&=&FileToRead
&&&ReadFile
End&Property
Public&Property&Get&FileName()&As&String
&&&&FileName&=&m_sFileName
End&Property
Public&Property&Get&FileSize()&As&Long
&&&FileSize&=&m_FileSize
End&Property
Public&Property&Get&IsVBR()&As&Boolean
&&&IsVBR&=&m_IsVBR
End&Property
Private&Sub&ReadFile()
&&&Dim&fn&As&Integer
&&&Dim&Y&As&Byte
&&&Dim&HeaderPosition&As&Long
&&&Dim&Tag1&As&udtID3v1Tag
&&&Dim&Tag2&As&String
&&&Dim&LyricEndID&As&String&*&6
&&&Dim&sFileExt&As&String
&&&UnknownLyrics3Fields&=&sEmpty
&&&On&Error&GoTo&Hell
&&&fn&=&FreeFile
&&&'sanity&check
&&&If&m_sFileName&=&sEmpty&Then&Exit&Sub
&&&Open&m_sFileName&For&Binary&As&#fn
&&&m_FileSize&=&LOF(fn)
&&&sFileExt&=&UCase$(Right$(m_sFileName,&3))
&&&Select&Case&sFileExt
&&&Case&&MP3&
&&&&&&'get&the&header
&&&&&&Get&#fn,&1,&B
&&&&&&If&B&&&&255&Then&'255&is&start&of&header
&&&&&&&&&If&B&&&&73&Then&Exit&Sub&&&&&&'start&of&id3v2&tag
&&&&&&End&If
&&&&&&HeaderPosition&=&1
&&&&&&Get&#fn,&2,&B
&&&&&&If&(B&&&250&Or&B&&&251)&Then&'next&part&of&header
&&&&&&&&&If&B&=&68&Then&'next&part&of&id3v2&tag...&one&more&to&be&sure
&&&&&&&&&&&&Get&#fn,&3,&B
&&&&&&&&&&&&If&B&=&51&Then&'last&identifier.&&It&is&indeed&a&id3v2&tag,&now&how&big&is&it?
&&&&&&&&&&&&&&&Dim&R&As&Double
&&&&&&&&&&&&&&&Get&#fn,&4,&Version
&&&&&&&&&&&&&&&Get&#fn,&7,&B
&&&&&&&&&&&&&&&R&=&B&*&
&&&&&&&&&&&&&&&Get&#fn,&8,&B
&&&&&&&&&&&&&&&R&=&R&+&(B&*&16384)
&&&&&&&&&&&&&&&Get&#fn,&9,&B
&&&&&&&&&&&&&&&R&=&R&+&(B&*&128)
&&&&&&&&&&&&&&&Get&#fn,&10,&B
&&&&&&&&&&&&&&&R&=&R&+&B
&&&&&&&&&&&&&&&If&R&&&m_FileSize&Or&R&&&&Then&Exit&Sub
&&&&&&&&&&&&&&&Tag2&=&Space$(R)
&&&&&&&&&&&&&&&Get&#fn,&11,&Tag2
&&&&&&&&&&&&&&&HeaderPosition&=&R&+&11&'this&is&where&the&header&should&be&if&there&are&no
&&&&&&&&&&&&End&If
&&&&&&&&&Else
&&&&&&&&&&&&Exit&Sub
&&&&&&&&&End&If
&&&&&&End&If
&&&&&&If&m_fReadTagOnly&Then&GoTo&ReadTags
&&&&&&'read&the&rest&of&the&header&to&get&bitrate,&etc.
&&&&&&Get&#fn,&HeaderPosition&+&2,&B
&&&&&&Y&=&B&And&240
&&&&&&Y&=&Y&\&16
&&&&&&m_BitRate&=&Val(Mid$(&144&16&&32&&48&&56&&64&&80&&96&&112&128&160&192&224&256&320&&,&Y&*&4&+&1,&4))
&&&&&&Y&=&B&And&12
&&&&&&Y&=&Y&\&2
&&&&&&m_Frequency&=&Val(Mid$(&44.1&48&&&32&&&00.0&&,&Y&*&5&+&1,&5))
&&&&&&'&check&to&see&if&it&is&a&xing&vbr&file
&&&&&&s&=&Space$(4)
&&&&&&Get&#fn,&HeaderPosition&+&36,&s
&&&&&&If&s&=&&Xing&&Then
&&&&&&&&&Dim&nFrames&As&Long
&&&&&&&&&Dim&FrameLength&As&Long
&&&&&&&&&m_IsVBR&=&True&&'We&have&a&xing&header...
&&&&&&&&&'get&the&number&of&frames&from&the&next&4&bytes.
&&&&&&&&&Get&#fn,&HeaderPosition&+&44,&B
&&&&&&&&&L&=&B
&&&&&&&&&Get&#fn,&HeaderPosition&+&45,&B
&&&&&&&&&'this&is&a&direct&translation&from&c++,&it&is&unusual&to&see&something
&&&&&&&&&'like&it&in&a&vb&routine.
&&&&&&&&&L&=&((B&And&255)&Or&(L&*&256))
&&&&&&&&&Get&#fn,&HeaderPosition&+&46,&B
&&&&&&&&&L&=&((B&And&255)&Or&(L&*&256))
&&&&&&&&&Get&#fn,&HeaderPosition&+&47,&B
&&&&&&&&&L&=&((B&And&255)&Or&(L&*&256))
&&&&&&&&&nFrames&=&L
&&&&&&&&&FrameLength&=&m_FileSize&/&nFrames
&&&&&&&&&m_BitRate&=&(FrameLength&*&(m_Frequency&*&1000))&/&144000
&&&&&&End&If
&&&&&&m_Duration&=&m_FileSize&/&(m_BitRate&*&125)&-&1
&&&Case&&WMA&
&&&&&&If&m_fReadTagOnly&Then&GoTo&ReadTags
&&&&&&For&i&=&1&To&1024
&&&&&&&&&Get&#fn,&i,&B
&&&&&&&&&If&B&=&0&Then
&&&&&&&&&&&&Get&#fn,&,&B
&&&&&&&&&&&&If&B&=&0&Then
&&&&&&&&&&&&&&&Get&#fn,&,&B
&&&&&&&&&&&&&&&If&B&=&0&Then
&&&&&&&&&&&&&&&&&&Get&#fn,&,&B
&&&&&&&&&&&&&&&&&&If&B&=&25&Then
&&&&&&&&&&&&&&&&&&&&&Get&#fn,&,&B
&&&&&&&&&&&&&&&&&&&&&If&B&=&0&Then
&&&&&&&&&&&&&&&&&&&&&&&&'we&should&have&the&kbps&here.
&&&&&&&&&&&&&&&&&&&&&&&&Get&#fn,&,&s
&&&&&&&&&&&&&&&&&&&&&&&&m_BitRate&=&Val(StrConv(s,&vbFromUnicode))
&&&&&&&&&&&&&&&&&&&&&&&&m_Duration&=&m_FileSize&/&(m_BitRate&*&126)
&&&&&&&&&&&&&&&&&&&&&&&&Exit&For
&&&&&&&&&&&&&&&&&&&&&End&If
&&&&&&&&&&&&&&&&&&End&If
&&&&&&&&&&&&&&&End&If
&&&&&&&&&&&&End&If
&&&&&&&&&End&If
&&&&&&Next&i
&&&Case&&MID&
&&&&&&If&m_fReadTagOnly&Then&Exit&Sub
&&&&&&CheckMid
&&&Case&Else
&&&&&&Exit&Sub
&&&End&Select
&&&'fixes&the&stupid&-01&second&error.
&&&If&m_Duration&&&0&Then&m_Duration&=&0
&&&'&now&get&the&tags
&&&'id3v1&tag.
&&&Get&#fn,&m_FileSize&-&127,&Tag1.id
&&&Get&#fn,&,&Tag1.Title
&&&Get&#fn,&,&Tag1.Artist
&&&Get&#fn,&,&Tag1.Album
&&&Get&#fn,&,&Tag1.Year
&&&Get&#fn,&,&ment
&&&Get&#fn,&,&Tag1.Genre
&&&'lyrics3&tag
&&&Get&#fn,&m_FileSize&-&136,&LyricEndID&'look&for&a&lyrics&3&tag
&&&'ok&now&check&for&valid&tags
&&&'in&the&correct&priority&as&processing&the&tags&will&fill&the&variables
&&&'ID3v1&tag?
&&&If&Tag1.id&=&&TAG&&Then
&&&&&&m_TagType&=&m_TagType&Or&ID3v1Tag
&&&&&&m_sTitle&=&Trim$(Tag1.Title)
&&&&&&m_sArtist&=&Trim$(Tag1.Artist)
&&&&&&m_sAlbum&=&Trim$(Tag1.Album)
&&&&&&m_sYear&=&Trim$(Tag1.Year)
&&&&&&m_sComment&=&Trim$(ment)
&&&&&&Genre&=&Tag1.Genre
&&&'id3v2&tag?
&&&If&Tag2&&&&sEmpty&Then&f&=&GetID3v2Tag(Tag2)
&&&If&f&Then&m_TagType&=&m_TagType&Or&ID3v2Tag
&&&'lyrics3&tag?
&&&If&LyricEndID&=&&LYRICS&&Then&'got&one,&go&get&it
&&&&&&HasLyrics3Tag&=&GetLyrics3Tag(True)
&&&&&&If&HasLyrics3Tag&Then&m_TagType&=&m_TagType&Or&Lyrics3Tag
&&&'everything&should&be&closed,&but&make&sure
&&&'if&no&tags,&then&get&info&from&filename
&&&If&m_TagType&=&NoTag&Then
&&&&&&GetInfoFromFileName
&&&m_fValidFile&=&True
&&&RaiseEvent&ReadComplete
&&&Exit&Sub
Private&Function&GetID3v2Tag(Tag2&As&String)&As&Boolean
&&&'decifer&the&tag
&&&'we&cheat&here&as&we&are&only&interested&in&certain&fields
&&&'we&only&look&for&those&and&ignore&everything&else
&&&Dim&TitleField&As&String
&&&Dim&ArtistField&As&String
&&&Dim&AlbumField&As&String
&&&Dim&YearField&As&String
&&&Dim&GenreField&As&String
&&&Dim&FieldSize&As&Long
&&&Dim&SizeOffset&As&Long
&&&Dim&FieldOffset&As&Long
&&&On&Error&GoTo&Hell
&&&Select&Case&Version
&&&&&&'set&the&fieldnames&for&version&2.0
&&&&&&TitleField&=&&TT2&
&&&&&&ArtistField&=&&TOA&
&&&&&&AlbumField&=&&TAL&
&&&&&&YearField&=&&TYE&
&&&&&&GenreField&=&&TCO&
&&&&&&FieldOffset&=&7
&&&&&&SizeOffset&=&5
&&&&&&'set&the&fieldnames&for&version&3.0
&&&&&&TitleField&=&&TIT2&
&&&&&&ArtistField&=&&TOPE&
&&&&&&AlbumField&=&&TALB&
&&&&&&YearField&=&&TYER&
&&&&&&GenreField&=&&TCON&
&&&&&&FieldOffset&=&11
&&&&&&SizeOffset&=&7
&&&Case&Else
&&&&&&'not&a&valid&tag,&exit
&&&&&&Exit&Function
&&&End&Select
&&&i&=&InStr(Tag2,&TitleField)
&&&If&i&&&0&Then
&&&&&&'read&the&title
&&&&&&FieldSize&=&Asc(Mid$(Tag2,&i&+&SizeOffset))&-&1
&&&&&&If&Version&=&3&Then
&&&&&&&&&'check&for&compressed&or&encrypted&field
&&&&&&&&&B&=&Asc(Mid$(Tag2,&i&+&9))
&&&&&&&&&If&(B&And&128)&=&True&Or&(B&And&64)&=&True&Then&GoTo&ReadAlbum
&&&&&&End&If
&&&&&&m_sTitle&=&Mid$(Tag2,&i&+&FieldOffset,&FieldSize)
ReadAlbum:
&&&i&=&InStr(Tag2,&AlbumField)
&&&If&i&&&0&Then
&&&&&&FieldSize&=&Asc(Mid$(Tag2,&i&+&SizeOffset))&-&1
&&&&&&If&Version&=&3&Then
&&&&&&&&&'check&for&compressed&or&encrypted&field
&&&&&&&&&B&=&Asc(Mid$(Tag2,&i&+&9))
&&&&&&&&&If&(B&And&128)&=&128&Or&(B&And&64)&=&64&Then&GoTo&ReadArtist
&&&&&&End&If
&&&&&&m_sAlbum&=&Mid$(Tag2,&i&+&FieldOffset,&FieldSize)
ReadArtist:
&&&i&=&InStr(Tag2,&ArtistField)
&&&If&i&&&0&Then
&&&&&&FieldSize&=&Asc(Mid$(Tag2,&i&+&SizeOffset))&-&1
&&&&&&If&Version&=&3&Then
&&&&&&&&&'check&for&compressed&or&encrypted&field
&&&&&&&&&B&=&Asc(Mid$(Tag2,&i&+&9))
&&&&&&&&&If&(B&And&128)&=&128&Or&(B&And&64)&=&64&Then&GoTo&ReadYear
&&&&&&End&If
&&&&&&m_sArtist&=&Mid$(Tag2,&i&+&FieldOffset,&FieldSize)
&&&i&=&InStr(Tag2,&YearField)
&&&If&i&&&0&Then
&&&&&&FieldSize&=&Asc(Mid$(Tag2,&i&+&SizeOffset))&-&1
&&&&&&If&Version&=&3&Then
&&&&&&&&&'check&for&compressed&or&encrypted&field
&&&&&&&&&B&=&Asc(Mid$(Tag2,&i&+&9))
&&&&&&&&&If&(B&And&128)&=&128&Or&(B&And&64)&=&64&Then&GoTo&ReadGenre
&&&&&&End&If
&&&&&&m_sYear&=&Mid$(Tag2,&i&+&FieldOffset,&FieldSize)
ReadGenre:
&&&i&=&InStr(Tag2,&GenreField)
&&&If&i&&&0&Then
&&&&&&FieldSize&=&Asc(Mid$(Tag2,&i&+&SizeOffset))&-&1
&&&&&&If&Version&=&3&Then
&&&&&&&&&'check&for&compressed&or&encrypted&field
&&&&&&&&&B&=&Asc(Mid$(Tag2,&i&+&9))
&&&&&&&&&If&(B&And&128)&=&128&Or&(B&And&64)&=&64&Then&GoTo&Done
&&&&&&End&If
&&&&&&s&=&Mid$(Tag2,&i&+&FieldOffset,&FieldSize)
&&&&&&If&Left$(s,&1)&=&&(&&Then
&&&&&&&&&Genre&=&Val(Mid$(s,&2,&2))
&&&&&&Else
&&&&&&&&&i&=&InStr(gsGenres,&s&&&Space$(22&-&Len(s)))
&&&&&&&&&If&i&&&0&Then
&&&&&&&&&&&&Genre&=&Int(i&/&22)
&&&&&&&&&End&If
&&&&&&End&If
&&&GetID3v2Tag&=&True
&&&Exit&Function
&&&'invalid&tag&exit
End&Function
Private&Function&GetLyrics3Tag(SaveInfo&As&Boolean)&As&Boolean
&&&On&Error&GoTo&Hell
&&&Dim&Position&As&Long
&&&Dim&FieldData&As&String
&&&Dim&FieldID&As&String&*&3
&&&Dim&FSZ&As&Integer
&&&Dim&fn&As&Integer
&&&Dim&Size&As&Long
&&&Dim&TagType&As&String&*&9
&&&Dim&Byte11Buffer&As&String&*&11
&&&Dim&Byte5Buffer&As&String&*&5
&&&'reset&size&of&tag
&&&LSZ&=&&000000&
&&&'open&the&file
&&&fn&=&FreeFile
&&&Open&m_sFileName&For&Binary&As&#fn
&&&'get&filesize
&&&Size&=&LOF(fn)
&&&'get&the&tag&END
&&&Get&#fn,&Size&-&136,&TagType
&&&'if&tag&is&valid&then
&&&If&TagType&=&&LYRICS200&&Then
&&&&&&'get&the&size&of&the&tag
&&&&&&Get&#fn,&Size&-&142,&LSZ
&&&&&&'set&the&position&to&the&first&byte
&&&&&&Position&=&Size&-&142&-&LSZ
&&&&&&'get&the&beginning&of&tag
&&&&&&Get&#fn,&Position,&Byte11Buffer
&&&&&&If&Byte11Buffer&&&&&LYRICSBEGIN&&Then
&&&&&&&&&'invalid&Lyrics3&version&2&tag!
&&&&&&&&&'we&don't&support&version&1...
&&&&&&&&&Close
&&&&&&&&&Exit&Function
&&&&&&End&If
&&&&&&'first&field
&&&&&&Position&=&Position&+&11
&&&&&&'keep&getting&fields&until&we&get&to&the&end&of&the&tag
&&&&&&Do&Until&Position&&=&Size&-&142
&&&&&&&&&'the&field&id
&&&&&&&&&Get&#fn,&Position,&FieldID
&&&&&&&&&'the&size&of&the&field
&&&&&&&&&Get&#fn,&Position&+&3,&Byte5Buffer
&&&&&&&&&FSZ&=&Val(Byte5Buffer)
&&&&&&&&&'make&room&for&the&data
&&&&&&&&&FieldData&=&Space(FSZ)
&&&&&&&&&'get&the&data
&&&&&&&&&Get&#fn,&Position&+&8,&FieldData
&&&&&&&&&'and&fill&the&approprate&field
&&&&&&&&&Select&Case&FieldID
&&&&&&&&&&&&Case&&LYR&
&&&&&&&&&&&&&&&m_sLyrics&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&INF&
&&&&&&&&&&&&&&&&m_sOtherInfo&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&AUT&
&&&&&&&&&&&&&&m_sAuthor&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&EAL&
&&&&&&&&&&&&&&&m_sAlbum&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&EAR&
&&&&&&&&&&&&&&&m_sArtist&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&ETT&
&&&&&&&&&&&&&&&m_sTitle&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&IMG&
&&&&&&&&&&&&&&&m_sImages&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&QUA&
&&&&&&&&&&&&&&&m_sQuality&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&SIT&
&&&&&&&&&&&&&&&m_sSituation&=&Trim$(FieldData)
&&&&&&&&&&&&Case&&MOO&
&&&&&&&&&&&&&&&m_sMood&=&Trim$(FieldData)
&&&&&&&&&&&&Case&Else
&&&&&&&&&&&&&&&'must&be&something&we&don't&know&about,&save&it.
&&&&&&&&&&&&&&&m_sUnknownFields&=&m_sUnknownFields&&&FieldID&&&Format(FSZ,&&00000&)&&&FieldData
&&&&&&&&&End&Select
&&&&&&&&&'now&set&the&postion&to&the&beginning&of&the&next&field
&&&&&&&&&Position&=&Position&+&8&+&FSZ
&&&&&&Loop
&&&&&&'set&the&flag
&&&&&&GetLyrics3Tag&=&True
&&&Exit&Function
&&&'close&all&open&files
End&Function
Public&Sub&Reset()
&&&'Load&Default&values...
&&&m_sTitle&=&sEmpty
&&&m_sArtist&=&sEmpty
&&&m_sAlbum&=&sEmpty
&&&m_sYear&=&&2000&
&&&m_sComment&=&sEmpty
&&&m_Genre&=&12
&&&m_Duration&=&0
&&&m_BitRate&=&0
&&&m_Frequency&=&0
&&&m_TagType&=&NoTag
&&&m_IsVBR&=&False
&&&m_sLyrics&=&sEmpty
&&&m_sQuality&=&sEmpty
&&&m_sSituation&=&sEmpty
&&&m_sMood&=&sEmpty
&&&m_sAuthor&=&sEmpty
&&&m_sOtherInfo&=&sEmpty
&&&m_sImages&=&sEmpty
&&&m_fValidFile&=&False
Public&Function&WriteTag()&As&Boolean
&&&Dim&WholeTag&As&String
&&&Dim&TagSize&As&String&*&6
&&&Dim&Position&As&Long
&&&Dim&MoveMP3Tag&As&Boolean
&&&Dim&fn&As&Integer
&&&Dim&UseOldInfo&As&Boolean
&&&Dim&Tag1&As&udtID3v1Tag
&&&Dim&NewLyr&As&Boolean
&&&WholeTag&=&sEmpty
&&&On&Error&GoTo&Hell
&&&If&Len(m_sTitle)&&&30&Then&NewLyr&=&True
&&&If&Len(m_sArtist)&&&30&Then&NewLyr&=&True
&&&If&Len(m_sAlbum)&&&30&Then&NewLyr&=&True
&&&If&m_sAuthor&&&&sEmpty&Then&NewLyr&=&True
&&&If&m_sImages&&&&sEmpty&Then&NewLyr&=&True
&&&If&m_sOtherInfo&&&&sEmpty&Then&NewLyr&=&True
&&&If&m_sLyrics&&&&sEmpty&Then&NewLyr&=&True
&&&If&m_sMood&&&&sEmpty&Then&NewLyr&=&True
&&&If&m_sQuality&&&&sEmpty&Then&NewLyr&=&True
&&&If&m_sSituation&&&&sEmpty&Then&NewLyr&=&True
&&&'build&the&tag
&&&If&NewLyr&=&True&Then
&&&&&&WholeTag&=&&LYRICSBEGIN&
&&&&&&Dim&IND&As&String
&&&&&&'the&IND&field&is&based&on&the&Lyrics&and&tagtype.&&If&there&are&no&lyrics&there&is&no&IND&field
&&&&&&'if&the&lyrcis&are&there,&it&is&&10&&if&it&also&has&timestamps&it&is&&11&
&&&&&&'ID&for&tag
&&&&&&IND&=&&00&
&&&&&&If&m_sLyrics&&&&sEmpty&Then
&&&&&&&&&IND&=&&10&
&&&&&&&&&If&InStr(1,&m_sLyrics,&&:&)&And&InStr(1,&m_sLyrics,&&]&)&Then&IND&=&&11&
&&&&&&End&If
&&&&&&WholeTag&=&WholeTag&&&&IND00002&&&&IND
&&&&&&'lyrics
&&&&&&If&m_sLyrics&&&&sEmpty&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&LYR&&&&Format(Len(m_sLyrics),&&00000&)&&&m_sLyrics
&&&&&&End&If
&&&&&&'other&info
&&&&&&If&m_sOtherInfo&&&&sEmpty&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&INF&&&&Format(Len(m_sOtherInfo),&&00000&)&&&m_sOtherInfo
&&&&&&End&If
&&&&&&'author
&&&&&&If&m_sAuthor&&&&sEmpty&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&AUT&&&&Format(Len(m_sAuthor),&&00000&)&&&m_sAuthor
&&&&&&End&If
&&&&&&'album
&&&&&&If&Len(m_sAlbum)&&&30&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&EAL&&&&Format(Len(m_sAlbum),&&00000&)&&&m_sAlbum
&&&&&&End&If
&&&&&&'artist
&&&&&&&If&Len(m_sArtist)&&&30&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&EAR&&&&Format(Len(m_sArtist),&&00000&)&&&m_sArtist
&&&&&&End&If
&&&&&&'title
&&&&&&If&Len(m_sTitle)&&&30&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&ETT&&&&Format(Len(m_sTitle),&&00000&)&&&m_sTitle
&&&&&&End&If
&&&&&&'images
&&&&&&If&m_sImages&&&&sEmpty&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&IMG&&&&Format(Len(m_sImages),&&00000&)&&&m_sImages
&&&&&&End&If
&&&&&&'quality
&&&&&&If&m_sQuality&&&&sEmpty&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&QUA&&&&Format(Len(m_sQuality),&&00000&)&&&m_sQuality
&&&&&&End&If
&&&&&&'situation
&&&&&&If&m_sSituation&&&&sEmpty&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&SIT&&&&Format(Len(m_sSituation),&&00000&)&&&m_sSituation
&&&&&&End&If
&&&&&&'mood
&&&&&&If&m_sMood&&&&sEmpty&Then
&&&&&&&&&WholeTag&=&WholeTag&&&&MOO&&&&Format(Len(m_sMood),&&00000&)&&&m_sMood
&&&&&&End&If
&&&&&&'append&the&unknown&fields
&&&&&&WholeTag&=&WholeTag&+&m_sUnknownFields
&&&&&&'calcuate&the&size
&&&&&&TagSize&=&Format(Len(WholeTag),&&000000&)
&&&&&&'append&the&end&identifier
&&&&&&WholeTag&=&WholeTag&&&TagSize&&&&LYRICS200&
&&&'prepare&for&writing
&&&fn&=&FreeFile
&&&Open&m_sFileName&For&Binary&As&#fn
&&&'set&to&just&before&the&current&id3&tag.
&&&Position&=&LOF(fn)&-&127
&&&'if&there&is&a&Lyrics3&tag,&then&go&back&to&the&beginning&of&the&old&one
&&&If&HasLyrics3Tag&Then&Position&=&Position&-&15&-&Val(LSZ)
&&&'&write&the&lyrics3&tag&if&there&is&one...
&&&If&WholeTag&&&&sEmpty&Then
&&&&&&Put&#fn,&Position,&WholeTag
&&&&&&Position&=&Seek(fn)
&&&'make&the&ld3tag
&&&Tag1.id&=&&TAG&
&&&Tag1.Title&=&m_sTitle
&&&Tag1.Artist&=&m_sArtist
&&&Tag1.Album&=&m_sAlbum
&&&ment&=&m_sComment
&&&Tag1.Year&=&m_sYear
&&&Tag1.Genre&=&m_Genre
&&&'write&the&id3tag
&&&Put&#fn,&Position,&Tag1
&&&'set&the&last&byte&of&the&file
&&&Position&=&Seek(fn)&-&1
&&&'make&sure&this&is&the&end&of&the&file&which&is&needed&if&this&tag&is&smaller&than&the&old&tag.
&&&SetFileLength&FileName,&Position
&&&RaiseEvent&WriteComplete
&&&Exit&Function
&&&Mbox&&WriteTags:&Error&&&&&Err.Description
End&Function
Private&Sub&SetFileLength(ByVal&FileName&As&String,&ByVal&NewLength&As&Long)
&&&'Will&cut&the&length&of&a&file&to&the&length&specified.
&&&Dim&hFile&As&Long
&&&'if&file&is&smaller&than&or&equal&to&requsted&length,&exit.
&&&If&FileLen(FileName)&&=&NewLength&Then&Exit&Sub
&&&'open&the&file
&&&hFile&=&CreateFile(FileName,&GENERIC_WRITE,&ZERO,&ByVal&ZERO,&OPEN_EXISTING,&FILE_FLAG_BACKUP_SEMANTICS,&0)
&&&'if&file&not&open&exit
&&&If&hFile&=&-1&Then&Exit&Sub
&&&'seek&to&position
&&&L&=&SetFilePointer(hFile,&NewLength,&ZERO,&ZERO)
&&&'and&mark&here&as&end&of&file
&&&SetEndOfFile&hFile
&&&'close&the&file
&&&L&=&CloseHandle(hFile)
Public&Sub&GetInfoFromFileName()
&&&Dim&Marker&As&Integer
&&&On&Error&GoTo&Hell
&&'separate&m_sFileName&from&Dir&(common&to&all&tag&structures
&&&i&=&InStrRev(m_sFileName,&sBSlash)
&&&s&=&Right$(m_sFileName,&Len(m_sFileName)&-&i)
&&&Marker&=&i&-&1&'set&marker&to&be&the&last&char&before&the&sbslash
&&&Select&Case&m_DirStructure
&&&&&&Case&0&'&No&Structure
&&&&&&&&&m_sTitle&=&s
&&&&&&&&&m_sArtist&=&sEmpty
&&&&&&&&&m_sAlbum&=&sEmpty
&&&&&&Case&1&'&artist\album\title
&&&&&&&&&m_sTitle&=&Left$(s,&Len(s)&-&4)&'take&off&the&.mp3
&&&&&&&&&i&=&InStrRev(m_sFileName,&sBSlash,&Marker)
&&&&&&&&&m_sAlbum&=&Mid$(m_sFileName,&i&+&1,&Marker&-&i)
&&&&&&&&&Marker&=&i&-&1&'set&marker&to&last&char&before&sbslash&again
&&&&&&&&&i&=&InStrRev(m_sFileName,&sBSlash,&Marker)
&&&&&&&&&m_sArtist&=&Mid$(m_sFileName,&i&+&1,&Marker&-&i)
&&&&&&Case&2&'artist\title
&&&&&&&&&'same&as&above,&only&one&less&loop
&&&&&&&&&m_sTitle&=&Left$(s,&Len(s)&-&4)
&&&&&&&&&i&=&InStrRev(m_sFileName,&sBSlash,&Marker)
&&&&&&&&&m_sArtist&=&Mid$(m_sFileName,&i&+&1,&Marker&-&i)
&&&&&&&&&m_sAlbum&=&sEmpty
&&&&&&Case&3&'&Artist&-&Title&...&this&may&not&always&work...
&&&&&&&&&s&=&Left$(s,&Len(s)&-&4)&'remove&extension
&&&&&&&&&i&=&InStr(s,&sDash)
&&&&&&&&&m_sTitle&=&Right$(s,&Len(s)&-&(i&+&2))
&&&&&&&&&m_sArtist&=&Left$(s,&i&-&1)
&&&&&&&&&m_sAlbum&=&sEmpty
&&&&&&Case&4&'Title&-&Artist
&&&&&&&&&s&=&Left$(s,&Len(s)&-&4)
&&&&&&&&&i&=&InStr(s,&sDash)
&&&&&&&&&m_sArtist&=&Right$(s,&Len(s)&-&(i&+&2))
&&&&&&&&&m_sTitle&=&Left$(s,&i&-&1)
&&&&&&&&&m_sAlbum&=&sEmpty
&&&End&Select
Public&Property&Get&DirStructure()&As&EDirStructure
&&&&&&&DirStructure&=&m_DirStructure
End&Property
Public&Property&Let&DirStructure(NewDirStructure&As&EDirStructure)
&&&&&&&m_DirStructure&=&NewDirStructure
End&Property
Private&Function&CheckMid()
&&&'This&function&cheats!&&Remove&it&before&trying&to&use&this&class
&&&'in&another&program.&&It&uses&variables&from&other&parts&of&the
&&&'program!&&Make&sure&you&also&remove&the&call&to&this&function.
&&&On&Error&GoTo&Hell
&&&Set&DXPlayer&=&New&FilgraphManager
&&&Set&DXPlayerPosition&=&DXPlayer
&&&'we&use&the&player&to&calculate&the&duration&of&the&midi&file
&&&DXPlayer.RenderFile&m_sFileName
&&&m_Duration&=&DXPlayerPosition.Duration
&&&'and&get&the&other&info&from&the&filename,&as&midis&can't&have&tags
&&&GetInfoFromFileName
&&&m_fValidFile&=&True
&&&Set&DXPlayerPosition&=&Nothing
&&&Set&DXPlayer&=&Nothing
End&Function
其他解决方案
为何我不能通过上面的代码呢?能够把VB的源码文件给我吗(在VB6中通过的)?我的Email:
我不会,帮你顶一顶
那天晚上,我突然很想喝酒,就喝了那半坛“醉生梦死”,好象平常一样,&
我继续做我的买卖。&
  老兄,看来你已经四十出头了吧,这四十几年来,总有事情你不愿再提,或&
者有些人你不愿意再见的。因为有些人对不起你,你就想杀了他们。但是你不敢&
,其实杀一个人很容易,一点也不麻烦。我有个朋友,他的武功非常好,最近生&
活有点困难,如果你能给他一点钱的话,他一定能帮你杀了他,考虑一下,不过&
要快……。&
  没事干的时候,我会望向白驼山。我清楚地记得曾经有一个女人在那边等着&
我,其实“醉生梦死”只不过是她和我开的一个玩笑,你越想知道自己是不是忘&
记的时候,你反而记得越清楚。&
  &我曾经听人说过,当你不能够再拥有,你唯一可以做的,就是令自己不要忘&
  不知道为什么,我常常会做同一个梦。没多久,我就离开了这个地方。&
  那天黄历上写着:驿马动,火逼金星,大利西方。&
其实你可以去下个FREE的,分析一下代码不就可以了么??
我折断了手臂,只为了曾去拥抱白云&
没人知道吗?
不要谢我:-)
不过要把所有的分都送给我:-)
发送出去了。
快点给分!
更多建议:1
赞助商广告}

我要回帖

更多关于 dtldrvhelp64.sys删除 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信