/ Published in: C++
Get version resource from a file (app, dll etc.).
Add version.lib to linker inputs.
Add version.lib to linker inputs.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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; }