Get version resource info for a file.


/ Published in: C++
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. // This function gets the file version info structure
  2. HRESULT GetFileVersion (char *filename, VS_FIXEDFILEINFO *pvsf) {
  3. DWORD dwHandle;
  4. DWORD cchver = GetFileVersionInfoSize(filename,&dwHandle);
  5. if (cchver == 0)
  6. return -1 ; // LastError();
  7. char* pver = new char[cchver];
  8. BOOL bret = GetFileVersionInfo(filename,dwHandle,cchver,pver);
  9. if (!bret)
  10. return -1 ; // LastError();
  11. UINT uLen;
  12. void *pbuf;
  13. bret = VerQueryValue(pver,"\\",&pbuf,&uLen);
  14. if (!bret)
  15. return -1 ; // LastError();
  16. memcpy(pvsf,pbuf,sizeof(VS_FIXEDFILEINFO));
  17. delete[] pver;
  18. return S_OK;
  19. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.