BOOL GetAppVersion( char *LibName
, WORD *MajorVersion
, WORD *MinorVersion
, WORD *BuildNumber
, WORD *RevisionNumber )
{
DWORD dwHandle, dwLen;
UINT BufLen;
LPTSTR lpData;
VS_FIXEDFILEINFO *pFileInfo;
dwLen = GetFileVersionInfoSizeA( LibName, &dwHandle );
if (!dwLen) return FALSE;
lpData = (LPTSTR) malloc (dwLen);
if (!lpData)
return FALSE;
if( !GetFileVersionInfoA( LibName, dwHandle, dwLen, lpData ) )
{
free (lpData); return FALSE;
}
if( VerQueryValueA( lpData, "\\", (LPVOID *) &pFileInfo, (PUINT)&BufLen ) )
{
*MajorVersion = HIWORD(pFileInfo->dwFileVersionMS);
*MinorVersion = LOWORD(pFileInfo->dwFileVersionMS);
*BuildNumber = HIWORD(pFileInfo->dwFileVersionLS);
*RevisionNumber = LOWORD(pFileInfo->dwFileVersionLS);
free (lpData); return TRUE;
}
free (lpData);
return FALSE;
}
转载于:https://blog.51cto.com/co63oc/1048745