I'm trying to use the code snippet shown at the end of this page to read multi-language version resource for executable files.
But, for example, when I run the code below for this file:
I get my nCnt
as 1
for only one resource, i.e. English.
What am I doing wrong?
LPCTSTR buff = L"path-to\\file.exe";
struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
DWORD dwDummy;
DWORD dwSz = GetFileVersionInfoSize(buff, &dwDummy);
if(dwSz > 0)
{
BYTE* pData = new (std::nothrow)BYTE[dwSz];
if(pData)
{
if(GetFileVersionInfo(buff, NULL, dwSz, pData))
{
//Get language info
UINT ncbSz;
LANGANDCODEPAGE* pLcp;
if(VerQueryValue(pData, L"\\VarFileInfo\\Translation", (VOID**)&pLcp, &ncbSz))
{
UINT nCnt = ncbSz / sizeof(struct LANGANDCODEPAGE);
CString strQuery;
UINT nczBufLn;
LPCTSTR pDescBuf;
for(UINT i = 0; i < nCnt; i++)
{
strQuery.Format(L"\\StringFileInfo\\%04x%04x\\FileDescription",
pLcp[i].wLanguage, pLcp[i].wCodePage);
if(VerQueryValue(pData, (LPTSTR)strQuery.GetString(), (VOID**)&pDescBuf, &nczBufLn))
{
wprintf(L"Description%d: %s\n", i, pDescBuf);
}
}
}
}
delete[] pData;
}
}