CString GetFileVersion() { CString strVersion = _T(""); HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); if (hRsrc != NULL) { HGLOBAL hGlobalMemory = LoadResource(NULL, hRsrc); if (hGlobalMemory != NULL) { CString rVersion; LPVOID pVersionResouece = LockResource(hGlobalMemory); LPVOID pVersion = NULL; DWORD uLength,langD; BOOL retVal; retVal = VerQueryValue(pVersionResouece, _T("\\VarFileInfo\\Translation"), (LPVOID*)&pVersion, (UINT*)&uLength); if (retVal && uLength == 4) { memcpy(&langD,pVersion,4); rVersion.Format(_T("\\StringFileInfo\\%02X%02X%02X%02X\\FileVersion"), (langD & 0xff00)>>8,langD & 0xff,(langD & 0xff000000)>>24, (langD & 0xff0000)>>16); } else { rVersion.Format(_T("\\StringFileInfo\\%04X04B0\\FileVersion"), GetUserDefaultLangID()); } if( VerQueryValue(pVersionResouece, rVersion.GetBuffer(0), (LPVOID*)&pVersion, (UINT *)&uLength) != 0 ) { strVersion.Format(_T("%s"), pVersion); } } FreeResource(hGlobalMemory); } return strVersion; }
Key Value FileVersion 1.1.3.7
C++
MFC
Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/C++/(MFC)Get VS_VERSION_INFO
last modified 2012-06-15 10:40:16