C/C++ code
BOOL GetAppVersion( char *LibName, WORD *MajorVersion, WORD *MinorVersion, WORD *BuildNumber, WORD *RevisionNumber )
{
DWORD dwHandle, dwLen;
UINT BufLen;
LPTSTR lpData;
VS_FIXEDFILEINFO *pFileInfo;
dwLen = GetFileVersionInfoSize( LibName, &dwHandle );
if (!dwLen)
return FALSE;
lpData = (LPTSTR) malloc (dwLen);
if (!lpData)
return FALSE;
if( !GetFileVersionInfo( LibName, dwHandle, dwLen, lpData ) )
{
free (lpData);
return FALSE;
}
if( VerQueryValue( 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;
}
如何读取文件的版本号
最新推荐文章于 2023-03-21 10:03:42 发布