Исходный код на VB.NET:
Code: Select all
Module All
Private Sub WriteLongTo(ByVal X As Long, ByVal Arr As Byte(), ByVal I As Integer)
For I = I To I + 7
Arr(I) = X And 255
X \= 256
Next I
End Sub
Private Sub WriteASCIIStringTo(ByVal Str As String, ByVal Arr As Byte(), ByVal I As Integer)
Dim Bytes() As Byte = (New ASCIIEncoding).GetBytes(Str)
For Q As Integer = 0 To Bytes.Count - 1
Arr(I + Q) = Bytes(Q)
Next Q
End Sub
Public Sub Main()
Dim OFD As New OpenFileDialog
OFD.FileName = Command$()
If Command$() <> "" OrElse OFD.ShowDialog() = DialogResult.OK Then
Try
Dim Filename As String = OFD.FileName
Dim Tail(611) As Byte ' Массив из 612 байт
Dim Size As Long = My.Computer.FileSystem.GetFileInfo(Filename).Length
Dim Url As String = InputBox("Введите url") & Chr(0)
Tail(0) = &HBA
Tail(1) = &H7
WriteLongTo(Size, Tail, &HC)
WriteLongTo(&H7FFFFFFFFFFFFFFF, Tail, &H14)
WriteASCIIStringTo("UURRLL", Tail, &H164)
WriteASCIIStringTo(Url, Tail, &H16A)
My.Computer.FileSystem.CopyFile(Filename, Filename & ".dmf")
My.Computer.FileSystem.WriteAllBytes(Filename & ".dmf", Tail, True)
If MsgBox("Открыть DMF-файл?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Готово") = MsgBoxResult.Yes Then
System.Diagnostics.Process.Start(Filename & ".dmf")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Ошибка")
End Try
End If
End Sub
End Module
PS: Кто знает DMF-формат, проверьте, пожалуйста, код.