Return to Snippet

Revision: 11786
at February 18, 2009 12:34 by jimfred


Initial Code
// This function gets the file version info structure 
HRESULT GetFileVersion (char *filename, VS_FIXEDFILEINFO *pvsf) { 
   DWORD dwHandle; 
   DWORD cchver = GetFileVersionInfoSize(filename,&dwHandle); 
   if (cchver == 0) 
      return -1 ; // LastError(); 
   char* pver = new char[cchver]; 
   BOOL bret = GetFileVersionInfo(filename,dwHandle,cchver,pver); 
   if (!bret) 
      return -1 ; // LastError(); 
   UINT uLen; 
   void *pbuf; 
   bret = VerQueryValue(pver,"\\",&pbuf,&uLen); 
   if (!bret) 
      return -1 ; // LastError(); 
   memcpy(pvsf,pbuf,sizeof(VS_FIXEDFILEINFO)); 
   delete[] pver; 
   return S_OK; 
}

Initial URL

                                

Initial Description
Get version resource from a file (app, dll etc.).
Add version.lib to linker inputs.

Initial Title
Get version resource info for a file.

Initial Tags

                                

Initial Language
C++