home
products
resource tuner console
sample scripts library
Localizing The Version Information
This code shows how to have an application display the Version Information in different languages depending upon the user's locale.
The script will create a copy of Version Information for the German language.
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 the FileVersion and ProductVersion entries using the placeholders
' plhd_VerMajor and plhd_VerMinor (see the values in LOCALIZE_VERSION_INFO.BAT);
' - Modify the existing String File Version Information;
' - Create a copy of Version Information for the German language;
' - (Optionally) Set every field in the PE file header, export and resource sections to the
' adjusted TimeDate stamp.
'
' Purpose: Have an application display the Version Information in different
' languages depending upon the user's locale.
'
' To give you an idea of how this all works, we made this sample script and
' a test application. When you installed Resorce Tuner Console on your computer,
' the setup program created the "Demo Scripts" folder under the RTC folder, with
' the test application "DemoApp1.exe" in the "Demo Scripts\Localize Version Info\Src" folder.
'
' The script will modify the Version Information in DemoApp1.exe using values from
' the placeholders and create a copy of Version Information
' for the German language.
'
' The resulting file will be created in the directory named "Release"
'------------------------------------------------------------------------------
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
'Set Language constants here
LangID_US = 1033 ' English-US
LangID_DE = 1031 ' German
PEFileProxy.PostDebugString "Opening a file..."
PEFileProxy.OpenFile ".\src\DemoApp1.exe"
if not PEFileProxy.Terminated then
if PEFileProxy.HasResources then
if ResourcesProxy.OpenVersionInfo("1", LangID_US, CREATE_IF_NOT_EXIST) then
'Modify the FileVersion and ProductVersion entries using the placeholders
VersionInfoProxy.SetFileVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0, LangID_US, True, True, True
VersionInfoProxy.SetProductVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0, LangID_US, True, True, True
CP = ScriptUnit.CodePageFromLangID(LangID_US)
PEFileProxy.PostDebugString "CodePage value for English-US: " & CStr(CP)
'Modify the existing String File Version Information
S1 = "My Company"
S2 = "Yet Another Super Application"
S3 = "Hot product"
S4 = "Copyright \0xA9 2013 My Company, Inc."
S5 = "Your trademarks here..."
S6 = "Super Application"
S7 = "5.1.Zero.Null"
VersionInfoProxy.EditStringFileInfo "CompanyName", S1, CP, LangID_US, True, True
VersionInfoProxy.EditStringFileInfo "FileDescription", S2, CP, LangID_US, True, True
VersionInfoProxy.EditStringFileInfo "InternalName", S3, CP, LangID_US, True, True
VersionInfoProxy.EditStringFileInfo "LegalCopyright", S4, CP, LangID_US, True, True
VersionInfoProxy.EditStringFileInfo "LegalTrademarks", S5, CP, LangID_US, True, True
VersionInfoProxy.EditStringFileInfo "ProductName", S6, CP, LangID_US, True, True
VersionInfoProxy.EditStringFileInfo "ProductVersion", S7, CP, LangID_US, True, True
ResourcesProxy.CloseVersionInfo
else
PEFileProxy.PostDebugString "Can't open/create Version Info..."
end if
'-------------------------------Begin Adding New Language (DE) -------------------------------
if ResourcesProxy.OpenVersionInfo("1", LangID_DE, CREATE_IF_NOT_EXIST) then
'Modify the FileVersion and ProductVersion entries using the placeholders
VersionInfoProxy.SetFileVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0, LangID_DE, True, True, True
VersionInfoProxy.SetProductVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0, LangID_DE, True, True, True
'Specify the general type of file: VFT_APP - an application, VFT_DLL - a DLL.
VersionInfoProxy.FileType = VFT_APP
CP = ScriptUnit.CodePageFromLangID(LangID_DE)
PEFileProxy.PostDebugString "CodePage value for German: " & CStr(CP)
'Add the String File Version Information for German version
S1 = "Meine Firma"
S2 = "Doch ein anderes Programm"
S3 = "Eine heisse Software für innovative Anwender"
S4 = "Copyright \0xA9 2013 Meine Firma GmbH"
S5 = "Alle Rechte vorbehalten"
S6 = "Super Programm"
S7 = "5.1.Null.Null"
VersionInfoProxy.EditStringFileInfo "CompanyName", S1, CP, LangID_DE, True, True
VersionInfoProxy.EditStringFileInfo "FileDescription", S2, CP, LangID_DE, True, True
VersionInfoProxy.EditStringFileInfo "InternalName", S3, CP, LangID_DE, True, True
VersionInfoProxy.EditStringFileInfo "LegalCopyright", S4, CP, LangID_DE, True, True
VersionInfoProxy.EditStringFileInfo "LegalTrademarks", S5, CP, LangID_DE, True, True
VersionInfoProxy.EditStringFileInfo "ProductName", S6, CP, LangID_DE, True, True
VersionInfoProxy.EditStringFileInfo "ProductVersion", S7, CP, LangID_DE, True, True
ResourcesProxy.CloseVersionInfo
else
PEFileProxy.PostDebugString "Can't open/create Version Info..."
end if
'-------------------------------End Adding New Language---------------------------------
'Optionally you can change the TimeDate stamp and set every field in the PE file header, export
'and resource sections to the adjusted TimeDate stamp.
MyDate = Now
PEFileProxy.UpdateDateTimeStamp MyDate
PEFileProxy.PostDebugString "Saving file as a new file image..."
PEFileProxy.SaveAsNewImage ".\release\DemoApp1.exe"
end if
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.
The Complete Illustrated Step by Step Guide To Using Scripts
Download Resource Tuner Console and learn how it can make you more productive.