Edit Strings: Example Of High Volume String Processing
This code shows the way you can edit the StringTable and MessageTable entries using Resource Tuner Console. You can edit as many entries as you wish in a number of files at once. You can repeat editing anytime.
The script edits the strings in the demo EXE (which shipped with the RTC package) using values from the definition file. It modifies the StringTable entries and adds a new MessageTable using the external Unicode text files "strings.txt" and "messages.txt". The modifed file is saved to the Destination folder.
This sample VBScript code provides a real-world example that demonstrates
many of the features available in Resource Tuner Console.
This code shows how to:
— Modify a String Table using values from an external unicode text file.
— Add a Message Table using values from an external unicode text file.
The script will modify strings in DemoApp1.exe
using string literal values from:
— definition file demoapp1.drc
in the "\Demo\defs\" folder
— unicode text file strings.txt
in the "\Demo\Src" folder
— unicode text file messages.txt
in the "\Demo\Src" folder
The resulting files will be created in the directory named "\Demo\Release".
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.
Sub Main PEFileProxy.PostDebugString "PE file header checksum updating is enabled." PEFileProxy.UpdateCheckSum = True PEFileProxy.PostDebugString "The creation of a backup copy is disabled." PEFileProxy.CreateBackUp = False PEFileProxy.PostDebugString "Open file..." PEFileProxy.OpenFile ".\demo\src\DemoApp1.exe" if (PEFileProxy.Terminated) then 'Issue a warning in case of error PEFileProxy.PostDebugString "Error when opening this file." else PEFileProxy.PostDebugString "File opened OK." if (not PEFileProxy.HasResources) then PEFileProxy.PostDebugString "The file contains no resources." else PEFileProxy.PostDebugString "The file contains resources." PEFileProxy.ClearDefinitions PEFileProxy.PostDebugString "Opening a definition file..." PEFileProxy.OpenDefinitionFile ".\demo\defs\demoapp1.drc" 'This specifies the default language LangID = 0 ' Default PEFileProxy.PostDebugString "Editing String Table using TXT file..." ResourcesProxy.EditStringTableFromFileW LangID, CREATE_IF_NOT_EXIST, ".\demo\src\strings.txt" PEFileProxy.PostDebugString "Adding a New Message Table using TXT file" ResourcesProxy.EditMessageTableFromFileW "1", LangID, CREATE_IF_NOT_EXIST, ".\demo\src\messages.txt" PEFileProxy.PostDebugString "Compiling all changes..." PEFileProxy.Compile PEFileProxy.PostDebugString "Saving file as a new file..." PEFileProxy.SaveAsNewImage ".\demo\release\DemoApp1.exe" end if PEFileProxy.PostDebugString "Closing this file..." PEFileProxy.CloseFile 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 nested in the directory where RTC has been installed. Within this Demo folder, there are 12 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.