Hi there,
I have some issue extracting files from Resource / Exe file.
I have a project with resource file named Project1.res and it's contents are:
I can extract the binary exe files from the resource file without any issue, but the one with ID 901 is getting me some trouble while trying to extract it.Code:AAA ICON MOVEABLE PRELOAD MAIN.ICO STRINGTABLE DISCARDABLE BEGIN 100 "1.1.0" END 800 CUSTOM "test1.exe" 900 CUSTOM "test2.exe" 901 CUSTOM "test2.conf"
For some reason the ID 901 after extracting will be corrupted by additional 2 bytes NULLs.Code:Call ExtractResFile("CUSTOM", 800, AppPath & "test1.exe") Call ExtractResFile("CUSTOM", 900, AppPath & "test2.exe") Call ExtractResFile("CUSTOM", 901, AppPath & "test2.conf") Private Function ExtractResFile(stResType As String, itResID As Integer, stExport2File As String) As Boolean On Error GoTo errh Dim byBin() As Byte Dim lgArray As Long Dim frFile As Integer frFile = FreeFile byBin = LoadResData(itResID, stResType) Open stExport2File For Output As frFile Do Until lgArray = UBound(byBin) + 1 Print #frFile, (Chr$(byBin(lgArray))); lgArray = lgArray + 1 DoEvents Loop Close frFile ExtractResFile = True Exit Function errh: Close frFile ExtractResFile = False Exit Function End Function
If I compile the Project EXE and run it from the IDE it will extract it properly from it, but if I run the compiled exe, then it will add NULL string at the end of the extracted file.
Any help would be appreciated!
btw...the ID 901 is 500Kb textual config file, others are Binaries.




Reply With Quote
