Results 1 to 12 of 12

Thread: [RESOLVED] Extract file from Res / Exe

Threaded View

  1. #1

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Resolved [RESOLVED] Extract file from Res / Exe

    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:

    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"
    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:
    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
    For some reason the ID 901 after extracting will be corrupted by additional 2 bytes NULLs.

    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.
    Last edited by beic; Sep 11th, 2018 at 06:52 AM. Reason: typo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width