CString CFileVersion::GetFixedProductVersion() { CString strVersion; VS_FIXEDFILEINFO vsffi; if ( GetFixedInfo(vsffi) ) { strVersion.Format (_T("%u,%u,%u,%u"), HIWORD(vsffi.dwProductVersionMS), LOWORD(vsffi.dwProductVersionMS), HIWORD(vsffi.dwProductVersionLS), LOWORD(vsffi.dwProductVersionLS)); } return strVersion; }
/////////////////////////////////////////////////////////////////////////////// // Init BOOL CMiniVersion::Init() { DWORD dwHandle; DWORD dwSize; BOOL rc; dwSize = ::GetFileVersionInfoSizeA((LPSTR)(LPCTSTR)m_szPath, &dwHandle); if (dwSize == 0) return FALSE; m_pData = new BYTE [dwSize + 1]; ZeroMemory(m_pData, dwSize+1); rc = ::GetFileVersionInfoA((LPSTR)(LPCTSTR)m_szPath, dwHandle, dwSize, m_pData); if (!rc) return FALSE; // get fixed info VS_FIXEDFILEINFO FixedInfo; if (GetFixedInfo(FixedInfo)) { m_wFileVersion[0] = HIWORD(FixedInfo.dwFileVersionMS); m_wFileVersion[1] = LOWORD(FixedInfo.dwFileVersionMS); m_wFileVersion[2] = HIWORD(FixedInfo.dwFileVersionLS); m_wFileVersion[3] = LOWORD(FixedInfo.dwFileVersionLS); m_wProductVersion[0] = HIWORD(FixedInfo.dwProductVersionMS); m_wProductVersion[1] = LOWORD(FixedInfo.dwProductVersionMS); m_wProductVersion[2] = HIWORD(FixedInfo.dwProductVersionLS); m_wProductVersion[3] = LOWORD(FixedInfo.dwProductVersionLS); m_dwFileFlags = FixedInfo.dwFileFlags; m_dwFileOS = FixedInfo.dwFileOS; m_dwFileType = FixedInfo.dwFileType; m_dwFileSubtype = FixedInfo.dwFileSubtype; } else return FALSE; // get string info GetStringInfo(_T("CompanyName"), m_szCompanyName); GetStringInfo(_T("FileDescription"), m_szFileDescription); GetStringInfo(_T("ProductName"), m_szProductName); return TRUE; }