读取文件的版本号,例如dll文件

 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;

}

 

[url=http://msdn.microsoft.com/en-us/library/ms647003(VS.85).aspx][/url]

你可能感兴趣的:(url,dll)