Glossary
A special resource type, the version stamp can be used to declare which language or languages a given executable or DLL supports. A setup program can check this stamp to ensure, for example, that it installs the correct language edition of a file. Programs can also access the version stamp at run time to verify which language resources are contained in available files.
The following excerpt is from a Win32 version stamp that includes both English and German translations.
#define
VER_FILEDESCRIPTION_STR_USA "Sample"
#define VER_FILEDESCRIPTION_STR_GER "Beispielanwendung"
#define VER_PRODUCTNAME_STR_USA \
"Sample\256"
#define VER_PRODUCTNAME_STR_GER \
"Beispielanwendung\256"
#define VER_INTERNALNAME_STR "Sample"
#define VER_ORIGINALFILENAME_STR "SAMPLE.EXE"
#define VER_PRODUCTVERSION_STR "1.65"
#define VER_LEGALCOPYRIGHT_YEARS "1991-1993"
#define VER_LEGALCOPYRIGHT_STR \
"Copyright \251 XYZ Corp." VER_LEGALCOPYRIGHT_YEARS
#define VER_FILEVERSION VER_PRODUCTVERSION
#define VER_COMPANYNAME_STR "XYZ Corp."
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VER_FILEFLAGSMASK
FILEFLAGS VER_FILEFLAGS
FILEOS VER_FILEOS
FILETYPE VER_FILETYPE
FILESUBTYPE VER_FILESUBTYPE
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0" /* LANG_ENGLISH/SUBLANG_ENGLISH_US,
Unicode CP */
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR_USA
END
BLOCK "040704B0" /* LANG_GERMAN/SUBLANG_DEFAULT,
Unicode CP */
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR_GER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x04B0, 0x0409L, 0x04B0, 0x0407L
/* Unordered list of Lang IDs and their code page IDs
(Unicode = 1200 in case of Win32). These can be
expressed using either hexadecimal or decimal. */
END
END
Note that each language ID appears at the beginning of a StringFileInfo block (to specify the language of the strings in the block of information) and at the end in the Translation field of the VarFileInfo block. The Translation field is a variable-length list of language IDs that indicates that resources in these different languages are available to the application. In the Visual C++ 2 editing environment, adding a new string block is a simple matter of clicking the mouse button on the right while editing a version resource, as shown below.
The following sample illustrates how an application might use version stamp information. Programs can call the function VerInstallFile to replace files on a hard disk with newer versions from installation disks. The function compares all language IDs in the Translation information of the source with all language IDs in the Translation information of the destination. The comparison is done in random order. If the language information in the new file does not match the language information of the file it is replacing, VerInstallFile returns an error code.
TCHAR szTemp[_MAX_PATH];
DWORD len = _MAX_PATH;
DWORD rc = VerInstallFile( NULL,
L"GER.DLL", // file to install
L"GER.DLL", // new name of file to install
L"A:\\LANGS\\", // source directory
L"C:\\APP\\", // installation directory
L"C:\\OLD", // existing version of file
szTemp,
&dwLen);
if (rc & VIF_DIFFLANG)
{
<languages differ>
}
else
{
<proceed>
}
Programs can also compare the version information in a DLL with version information contained in a corresponding EXE to make sure that the correct version of the DLL is installed on the user's computer. In general, when you have the option, choose a DLL that has the correct version number over one that supports a particular language. After all, without the correct version of a DLL, your program probably won't work properly.