具体想要某个指定的版本信息,可在资源文件中查看对应标题.
/
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,0,0,1
PRODUCTVERSION 5,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "Comments", "*****************\0"
VALUE "CompanyName", "********************\0"
VALUE "FileDescription", "***************程序\0"
VALUE "FileVersion", "5, 0, 0, 1\0"
VALUE "InternalName", "**************\0"
VALUE "LegalCopyright", "********************* 版权所有 (C) 2016\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "***************.EXE\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "************* 应用程序\0"
VALUE "ProductVersion", "5, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
END
END
#endif // !_MAC
void CAboutDlg::ReadVersion(CString& strVersion, CString& strCopyriht)
{
char szAppFullPath[_MAX_PATH] = {0};
::GetModuleFileName(NULL, szAppFullPath, _MAX_PATH);
DWORD dwLen = GetFileVersionInfoSize(szAppFullPath, NULL);
char *pszAppVersion = new char[dwLen + 1];
if (NULL != pszAppVersion)
{
ZeroMemory(pszAppVersion, dwLen + 1);
::GetFileVersionInfo(szAppFullPath, 0, dwLen, pszAppVersion);
UINT nLen = 0;
char *pInfo = NULL;
CString strVersionValues;
struct LANGANDCODEPAGE{
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
VerQueryValue(pszAppVersion, "\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &nLen);
strVersionValues.Format(_T("\\StringFileInfo\\%04x%04x\\FileVersion"),
lpTranslate->wLanguage,lpTranslate->wCodePage);
VerQueryValue(pszAppVersion, strVersionValues.GetBuffer(strVersionValues.GetLength()),
(LPVOID*)&pInfo, &nLen);
strVersion = pInfo;
strVersionValues.Format(_T("\\StringFileInfo\\%04x%04x\\LegalCopyright"),
lpTranslate->wLanguage,lpTranslate->wCodePage);
VerQueryValue(pszAppVersion, strVersionValues.GetBuffer(strVersionValues.GetLength()),
(LPVOID*)&pInfo, &nLen);
m_strCopyriht = pInfo;
delete[] pszAppVersion;
pszAppVersion = NULL;
lpTranslate = NULL;
pInfo = NULL;
}
}