CString GetProductName()
{
DWORD dwSize,dwHandle;
BYTE *byData, *lpName;
char sAppName[MAX_PATH];
CString strName;
unsigned int uLen;
//获得版本号
sprintf(sAppName,"%s.exe",AfxGetApp()->m_pszExeName);//若为MFC程序, 可用此句获得当前程序(或DLL)文件所在目录
dwSize=GetFileVersionInfoSize(sAppName,&dwHandle);
byData=new BYTE[dwSize+10];
memset(byData, 0, dwSize+10);
GetFileVersionInfo(sAppName,NULL,dwSize,byData);
VerQueryValue(byData,TEXT("\\StringFileInfo\\080403a8\\ProductName"),(void **)&lpName, &uLen);
//去掉版本号的最后一位,并将','改为'.'
strName=lpName;
strName.Replace(",",".");
strName.Replace(" ","");
delete [] byData;
return strName;
}
CString GetProductVersion()
{
DWORD dwSize,dwHandle;
BYTE *byData, *lpVers;
char sAppName[MAX_PATH];
CString strVersion;
unsigned int uLen;
//获得版本号
sprintf(sAppName,"%s.exe",AfxGetApp()->m_pszExeName);//若为MFC程序, 可用此句获得当前程序(或DLL)文件所在目录
dwSize=GetFileVersionInfoSize(sAppName,&dwHandle);
byData=new BYTE[dwSize+10];
memset(byData, 0, dwSize+10);
GetFileVersionInfo(sAppName,NULL,dwSize,byData);
VerQueryValue(byData,TEXT("\\StringFileInfo\\080403a8\\ProductVersion"),(void **)&lpVers, &uLen);
//去掉版本号的最后一位,并将','改为'.'
strVersion=lpVers;
strVersion.Replace(",",".");
strVersion.Replace(" ","");
delete [] byData;
return strVersion;
}