English English  Deutsch Deutsch

Adding or Replacing Bitmaps from .BMP Files

This code shows how to replace bitmaps (.BMP) in EXE and DLL files using Resource Tuner Console.

The script adds or replaces bitmaps in the demo EXE (which shipped with the RTC package) with bitmaps from .bmp files in the "Demo\Src" folder. The resulted file is saved to the Destination folder.

Note: when copying out the script code, please make sure there's no line breaks. This is a requirement of VBScript: the entire command must be on one line.

' This code shows how to modify bitmaps in executables.
' The script will add or replace bitmaps in demoapp1.exe with bitmaps from .bmp
' files in the "Src" folder, and output the changes in the Resource Tree 
' to a log file.
' The resulting files will be created in the directory named "Demo\Release"
' Check the log file to see the Resource Tree built. 

Sub Main
  PEFileProxy.PostDebugString "Updating the checksum in the PE file header is enabled." 
  PEFileProxy.UpdateCheckSum = True 

  PEFileProxy.PostDebugString "The creation of a backup copy is disabled." 
  PEFileProxy.CreateBackUp = False 

  PEFileProxy.PostDebugString "Opening the demo file..."
  PEFileProxy.OpenFile ".\src\DemoApp1.exe"
  if (PEFileProxy.Terminated) then
    PEFileProxy.PostDebugString "Fatal error when opening the file."
    PEFileProxy.PostDebugString "File successfully opened."
    if (not PEFileProxy.HasResources) then
      PEFileProxy.PostDebugString "The file contains no resources."
      PEFileProxy.PostDebugString "The file contains resources."

      LangID = 0 ' Default

      ResourcesProxy.SetLanguage LangID, DELETE_IF_EXISTS

PEFileProxy.PostDebugString "Changing/adding the bitmap..."
ResourcesProxy.ChangeBitmap "THEBITMAP", LangID, CREATE_IF_NOT_EXIST, ".\src\thebitmap.bmp"

      PEFileProxy.PostDebugString ""
      PEFileProxy.PostDebugString "Resource Tree built by RTC:"
      PEFileProxy.PostDebugString ""

      PEFileProxy.PostDebugString "Saving file as a new file..."
      PEFileProxy.SaveAsNewImage ".\release\DemoApp1.exe"
    end if
    PEFileProxy.PostDebugString "Closing this file..."
  end if
end Sub

To see the changes made to the test EXEs, we recommend using Resource Tuner GUI, a visual resource editor.

Once installed Resorce Tuner Console, you will find the Demo folder in the directory where RTC has been installed. Within this Demo folder, there are 11 subdirectories that contain sample scripts and sample executable files.

All sample scripts are ready to run. Select one of the .BAT files located in the Demo folders to execute the sample script. The script will make changes in the test EXE file. The resulting file will be created in the directory named "Release" under the directory containing the script.

 Download Resource Tuner Console and learn how it can make you more productive.