Prev: SetWindowsHookEx
Next: LVM_SETVIEW
From: finerio on 5 Jan 2006 10:24 Search keywords: GetFileVersionInfo example GetFileVersionInfo example C++ GetFileVersionInfo example Visual C++ GetFileVersionInfo example Visual C++ XP How to use GetFileVersionInfo How to get a file's version under Windows XP ---------------------------------------------------------------- It is based on another post but it was so hard to find that I had to post a full example for the next generations. It's a shame that it takes such a long procedure just to get such basic information. ---------------------------------------------------------------- Project settings: add Version.lib to libraries. ---------------------------------------------------------------- #include <windows.h> #include <tchar.h> #include <stdio.h> void main() { LPTSTR lpszFilePath = "E:\\Test\\MyTest.exe"; DWORD dwDummy; DWORD dwFVISize = GetFileVersionInfoSize( lpszFilePath , &dwDummy ); LPBYTE lpVersionInfo = new BYTE[dwFVISize]; GetFileVersionInfo( lpszFilePath , 0 , dwFVISize , lpVersionInfo ); UINT uLen; VS_FIXEDFILEINFO *lpFfi; VerQueryValue( lpVersionInfo , _T("\\") , (LPVOID *)&lpFfi , &uLen ); DWORD dwFileVersionMS = lpFfi->dwFileVersionMS; DWORD dwFileVersionLS = lpFfi->dwFileVersionLS; delete [] lpVersionInfo; printf( "Higher: %x\n" , dwFileVersionMS ); printf( "Lower: %x\n" , dwFileVersionLS ); DWORD dwLeftMost = HIWORD(dwFileVersionMS); DWORD dwSecondLeft = LOWORD(dwFileVersionMS); DWORD dwSecondRight = HIWORD(dwFileVersionLS); DWORD dwRightMost = LOWORD(dwFileVersionLS); printf( "Version: %d.%d.%d.%d\n" , dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost ); }
|
Pages: 1 Prev: SetWindowsHookEx Next: LVM_SETVIEW |