// Get the version information size for allocate the buffer
DWORD dwHandle;
DWORD dwDataSize = ::GetFileVersionInfoSize((LPTSTR)lpszModuleName, &dwHandle);
if ( dwDataSize == 0 )
return FALSE;
// Allocate buffer and retrieve version information
m_lpVersionData = new BYTE[dwDataSize];
if (!::GetFileVersionInfo((LPTSTR)lpszModuleName, dwHandle, dwDataSize,
(void**)m_lpVersionData) )
{
Close();
return FALSE;
}
// Retrieve the first language and character-set identifier
UINT nQuerySize;
DWORD* pTransTable;
if (!::VerQueryValue(m_lpVersionData, _T("\\VarFileInfo\\Translation"),
(void **)&pTransTable, &nQuerySize) )
{
Close();
return FALSE;
}
// Swap the words to have lang-charset in the correct format
m_dwLangCharset = MAKELONG(HIWORD(pTransTable[0]), LOWORD(pTransTable[0]));