Как должно быть
Что выходит в итоге
Сам код программы
- Код: Выделить всё
Module Module1
Private Declare Function BeginUpdateResource Lib "kernel32.dll" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Boolean) As Long
Private Declare Function UpdateResource Lib "kernel32.dll" Alias "UpdateResourceA" (ByVal hUpdate As IntPtr, ByVal lpType As Integer, ByVal lpName As Integer, ByVal wLanguage As System.UInt16, ByVal lpData As IntPtr, ByVal cbData As UInteger) As Boolean
Private Declare Function EndUpdateResource Lib "kernel32.dll" Alias "EndUpdateResourceA" (ByVal hUpdate As IntPtr, ByVal fDiscard As Boolean) As Boolean
Private Declare Function FindResource Lib "kernel32.dll" Alias "FindResourceA" (ByVal hModule As IntPtr, ByVal lpName As Byte, ByVal lpType As Byte) As IntPtr
Private Declare Function SizeofResource Lib "kernel32.dll" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As Long
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpFileName As String) As IntPtr
Private Declare Function LoadResource Lib "kernel32.dll" Alias "LoadResource" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
Private Declare Function LockResource Lib "kernel32.dll" Alias "LockResource" (ByVal hResData As IntPtr) As IntPtr
Sub Main()
Dim k1 As Long = LoadLibrary("smath.exe")
Dim k2 As Long = FindResource(k1, 1, 16)
Dim k3 As Long = SizeofResource(k1, k2)
Dim k4 As Long = LoadResource(k1, k2)
Dim k5 As Long = LockResource(k4)
'Dim kbyte(k3 - 1) As Byte
'Runtime.InteropServices.Marshal.Copy(k5, kbyte, 0, k3)
'For i As Integer = 0 To k3 - 1
' Console.Write(Chr(kbyte(i)))
'Next
'Console.ReadLine()
Dim a As Long = BeginUpdateResource("GuideMain.exe", False)
Dim b = UpdateResource(a, 16, 1, 0, k5, k3)
EndUpdateResource(a, False)
End Sub
End Module
Набор EXE для проверки