MPM=>MP3的VB源码 (3千字)
MPM=>MP3的VB源码hdy 2002.04.01
因朋友需要,现将此源码贴出,此代码在VB5下编译通过。为什么用VB5是因为win98带有vb5的运行库,软件不需要安装,所以很方便。
Form上共6个控件:
Drive1: DriveListBox
Dir1: DirListBox
File1: FileListBox
File2: FileListBox
txtMsg: TextBox
cmdHelp: CommandButton
属性都不用修改。
下面是源代码:
Option Explicit
'''''''''''''''''''''''''''''''''
' MPM => MP3 的工具
'
' hdy 2002.04.01
'
''''''''''''''''''''''''''''''''
Private Sub cmdHelp_Click()
Dim Str As String
Str = "此工具用于将MP3播放器内存储的MPM文件格式还原为MP3文件格式。" & vbCrLf & vbCrLf _
& "破解mpm文件不能上传: " & vbCrLf _
& "DM-N64.exe 文件 50 FF 15 A8 E0 45 00 => 50 90 90 90 90 90 90 " & vbCrLf _
& "MPMan-F60.exe 文件 50 FF 15 4C E4 45 00 => 50 90 90 90 90 90 90" & vbCrLf & vbCrLf _
& "此工具在MSC的""DM-N64""上通过测试。" & vbCrLf & vbCrLf _
& " ---- hdy 2002.04.01"
MsgBox Str, vbInformation, "帮助"
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
File2.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error GoTo errh
Dir1.Path = Drive1.Drive
Drive1.Tag = Drive1.Tag
Exit Sub
errh:
Drive1.Drive = Drive1.Tag
End Sub
Private Sub File1_DblClick()
Dim filemp3() As Byte
Dim filempm() As Byte
Dim FileName As String
Dim FileLength As Long
Dim Position As Long
Dim i As Long, j As Long
On Error GoTo errh
Me.Enabled = False
Me.MousePointer = 11
'取得mpm绝对文件名
FileName = IIf(Right(File1.Path, 1) = "\", File1.Path & File1.FileName, File1.Path & "\" & File1.FileName)
Open FileName For Binary Access Read As #1
FileLength = LOF(1)
ReDim filempm(FileLength) As Byte
ReDim filemp3(FileLength - 33) As Byte
'读取mpm文件
Get #1, , filempm
txtMsg = "转换 " & FileName & " 为mp3文件..."
txtMsg.Refresh
j = 512 * ((FileLength - 32) \ 512) '计算实际要进行转换的数据总数
For i = 0 To j - 1
'数据转换 (每512个字节作为一个转换单元)
Position = ((i Mod 512) \ 32) + 16 * ((i Mod 512) Mod 32) + 512 * (i \ 512)
filemp3(Position) = filempm(i) - 2 * (filempm(i) Mod 2) + 1
Next i
For i = j To FileLength - 32 - 1
'剩余的字节直接拷贝
filemp3(i) = filempm(i)
Next i
Close #1
FileName = Left(FileName, Len(FileName) - 4) & ".mp3"
Open FileName For Binary Access Write As #1
'写入mp3文件
Put #1, , filemp3
Close #1
txtMsg = "转换完毕,生成 " & FileName & " 文件。"
File2.Refresh
Me.MousePointer = 0
Me.Enabled = True
Exit Sub
errh:
Close #1
File1.Refresh
Me.MousePointer = 0
Me.Enabled = True
End Sub
Private Sub Form_Load()
Drive1.Tag = Drive1.Drive
File1.Pattern = "*.mpm"
File2.Pattern = "*.mp3"
End Sub
