Example:
CString strResult;
TCHAR szModPath[MAX_PATH];
ZeroMemory(szModPath, sizeof(TCHAR) * MAX_PATH);
GetModuleFileName(NULL, szModPath, sizeof(szModPath));
DWORD dwHandle;
DWORD dwSize = GetFileVersionInfoSize(szModPath, &dwHandle);
if (dwSize > 0)
{
BYTE* pbBuf = static_cast<BYTE*>(alloca(dwSize));
if (GetFileVersionInfo(szModPath, dwHandle, dwSize, pbBuf))
{
UINT uiSize;
BYTE* lpb;
if (VerQueryValue(pbBuf, L"\\VarFileInfo\\Translation", (void**)&lpb, &uiSize))
{
WORD* lpw = (WORD*)lpb;
CString strQuery;
strQuery.Format(L"\\StringFileInfo\\%04x%04x\\ProductVersion", lpw[0], lpw[1]);
if (VerQueryValue(pbBuf, const_cast<LPTSTR>((LPCTSTR)strQuery), (void**)&lpb, &uiSize ) && uiSize > 0)
{
strResult = (LPCTSTR)lpb;
}
}
}
}
沒有留言:
張貼留言