I really confuse with this function. currently i success to retrieve File Version and Product Version. now i want to retrieve more information within application. like FileDescr
VerQueryValue(test, "\\StringFileInfo\\%04x%09x\\FileDescription", (LPVOID*)&sCompanyName, &pLenFileInfo);
The second parameter should be of this format "\\StringFileInfo\\NxM\\FileDescription"
where N
and M
are wLanguage
and wCodePage
. Following the example in comment section, you can use "%04x%04x"
as print format specifier to create a string. Example:
BOOL foo()
{
const char* filename = "c:\\windows\\hh.exe";
int dwLen = GetFileVersionInfoSize(filename, NULL);
if(!dwLen)
return 0;
auto *sKey = new BYTE[dwLen];
std::unique_ptr skey_automatic_cleanup(sKey);
if(!GetFileVersionInfo(filename, NULL, dwLen, sKey))
return 0;
struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
UINT cbTranslate = 0;
if(!VerQueryValue(sKey, "\\VarFileInfo\\Translation",
(LPVOID*)&lpTranslate, &cbTranslate))
return 0;
for(unsigned int i = 0; i < (cbTranslate / sizeof(LANGANDCODEPAGE)); i++)
{
char subblock[256];
//use sprintf if sprintf_s is not available
sprintf_s(subblock, "\\StringFileInfo\\%04x%04x\\FileDescription",
lpTranslate[i].wLanguage, lpTranslate[i].wCodePage);
char *description = NULL;
UINT dwBytes;
if(VerQueryValue(sKey, subblock, (LPVOID*)&description, &dwBytes))
MessageBox(0, description, 0, 0);
}
return TRUE;
}