Private Declare Function BeginUpdateResource Lib "kernel32" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Long) As Long
Private Declare Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As Long, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function EndUpdateResource Lib "kernel32" Alias "EndUpdateResourceA" (ByVal hUpdate As Long, ByVal fDiscard As Long) As Long
Private Declare Function FindResourceEx Lib "kernel32" Alias "FindResourceExA" (ByVal hModule As Long, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function LockResource Lib "kernel32" (ByVal hResData As Long) As Long
Private Declare Function SizeofResource Lib "kernel32" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long
Private Declare Function LoadResource Lib "kernel32" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Sub WriteRES(sFile As String, sData As String, sType As String, sName As String)
Dim h As Long
h = BeginUpdateResource(sFile, 0)
Call UpdateResource(h, sType, sName, 1049, ByVal sData, Len(sData)) '1049 - язык
Call EndUpdateResource(h, 0)
End Sub
Public Function ReadRES(sFile As String, sType As String, sName As String) As String
Dim txt As String
Dim hgRes As Long
hLib = LoadLibrary(sFile)
hRes = FindResourceEx(hLib, ByVal sType, ByVal sName, 1049)
hLRes = LoadResource(hLib, hRes)
hgRes = LockResource(hLRes)
lenRes = SizeofResource(hLib, hRes)
txt = Space(lenRes)
CopyMemory ByVal txt, ByVal hgRes, lenRes
FreeLibrary hLib
ReadRES = txt
End Function
Ответить
|