If needed, you can support multiple languages in your version information:
Code:
// Sample version information...
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0 // Use this binary version number instead of a localized string - see below
PRODUCTVERSION 1,0,0,0
FILEOS VOS_NT
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
{
BLOCK "040904B0"
{
VALUE "CompanyName", "Company name in English"
VALUE "FileDescription", "File description in English"
VALUE "FileVersion", "1.0.0.0"
// Other values
}
BLOCK "081304B0"
{
VALUE "CompanyName", "Company name in Belgian Dutch"
VALUE "FileDescription", "File description in Belgian Dutch"
VALUE "FileVersion", "1.0.0.0"
// Other values
}
}
}
Instead of using a string version, for internal purposes you are probably better off using the binary version number:
Code:
void ShowFileVersion(void)
{
DWORD versioninfo_size;
void* versioninfo;
VS_FIXEDFILEINFO * fixed_info;
UINT cbLength;
DWORD dwDummy;
TCHAR szModulePath[MAX_PATH];
CHAR szBuf[200];
/* Get the complete path to the module(DLL or EXE) we are executing in. */
if (0 == GetModuleFileName(NULL, szModulePath, MAX_PATH))
{
return FALSE;
}
/* Get the size of the version information resource in the file. */
versioninfo_size = GetFileVersionInfoSize(szModulePath, &dwDummy);
if (0 == versioninfo_size)
{
return FALSE;
}
/* Allocate memory for the version information resource. */
versioninfo = malloc(versioninfo_size);
if (NULL = versioninfo)
{
return FALSE;
}
/* Get the version information resource in our buffer. */
if (!GetFileVersionInfo(szModulePath, 0, versioninfo_size, versioninfo))
{
free(versioninfo);
return FALSE;
}
/* Get a pointer to the fixed file version info in fixed_info. */
if (!VerQueryValue(versioninfo,"\\", (void **) &fixed_info, &cbLength) ||
cbLength < sizeof(VS_FIXEDFILEINFO) || NULL == fixed_info)
{
free(versioninfo);
return FALSE;
}
/* Use the values in fixed_info. */
{
TCHAR buf[256];
wsprintf(buf, TEXT("The version of this file is %d.%d"),
fixed_info->dwFileVersionMS, fixed_info->dwFileVersionLS);
MessageBox(NULL, buf, TEXT("File Version"), NULL, 0);
}
free(versioninfo);
return TRUE;
}
This will also be easier to compare against.