Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winver.h; include Windows.h.
Library: Use Version.lib.
TCHAR szApp[MAX_PATH] = {0};
GetModuleFileName(NULL,szApp,MAX_PATH);
DWORD dwVerInfoSize = GetFileVersionInfoSize(szApp,0);
ASSERT(dwVerInfoSize>0);
BYTE *pVerInfor = new BYTE[dwVerInfoSize];
if(!pVerInfor)
{
ASSERT(pVerInfor);
return;
}
VERIFY(GetFileVersionInfo(szApp,0,dwVerInfoSize,pVerInfor));
VS_FIXEDFILEINFO *pVsInfo = NULL;
UINT uVerSize = 0;
CString strWinText,strVer;
if(VerQueryValue(pVerInfor,_T("\\"),(LPVOID*)&pVsInfo,&uVerSize))
{
VERIFY(uVerSize == sizeof(VS_FIXEDFILEINFO));
strVer.Format(_T(" [ Ver:%d.%d ]"),
HIWORD(pVsInfo->dwProductVersionMS),
LOWORD(pVsInfo->dwProductVersionMS));
//TRACE("当前App版本为 %s \n", strVer);
}
评论