Nasao sam resenje.
Code:
struct Var {
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[11];
WORD Padding[1];
VS_FIXEDFILEINFO Value;
};
...
DWORD dwVerHnd=0;
DWORD dwVerInfoSize = GetFileVersionInfoSize (file_name, &dwVerHnd);
if (!dwVerInfoSize) // Cannot reach the DLL file
return 1;
LPSTR lpstrVffInfo =
(LPSTR) new char[dwVerInfoSize]; // Alloc memory for file inf
if (!GetFileVersionInfo(file_name, dwVerHnd, dwVerInfoSize, lpstrVffInfo)) {
delete [] lpstrVffInfo;
return 2; // Cannot read the file information -
// wierd, since we could read the information size
}
Var *var = (Var *)lpstrVffInfo;
_snprintf(version_string, version_string_size, "%d,%d,%d,%d",
int(var->Value.dwProductVersionMS >> 16),
int(var->Value.dwProductVersionMS & 0xFFFF),
int(var->Value.dwProductVersionLS >> 16),
int(var->Value.dwProductVersionLS & 0xFFFF));
delete [] lpstrVffInfo;