#pragma comment(lib, "Version.lib")
BOOL GetFileVersionInfoTmp(char* szFileName )
{
if (NULL == szFileName)
{
AfxMessageBox("调用程序路径为空");
return FALSE;
}
DWORD dwSize = GetFileVersionInfoSize(szFileName,NULL);
LPVOID pBlock = malloc(dwSize);
GetFileVersionInfo(szFileName,0,dwSize,pBlock);
CString strMsg;
char* pVerValue = NULL;
UINT nSize = 0;
VerQueryValue(pBlock,TEXT( "\\VarFileInfo\\Translation"), (LPVOID*)&pVerValue,&nSize);
CString strSubBlock,strTranslation,strTemp;
strTemp.Format( "000%x",*((unsigned short int *)pVerValue));
strTranslation = strTemp.Right(4);
strTemp.Format( "000%x",*((unsigned short int *)&pVerValue[2]));
strTranslation += strTemp.Right(4);
//strTranslation 080404b0为中文,040904E4为英文
//文件描述
strSubBlock.Format("\\StringFileInfo\\%s\\FileDescription",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s 文件描述: %s\r",strMsg,pVerValue);
//内部名称
strSubBlock.Format("\\StringFileInfo\\%s\\InternalName",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s 内部名称: %s\r",strMsg,pVerValue);
//合法版权
strSubBlock.Format("\\StringFileInfo\\%s\\LegalTradeMarks",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s 合法版权: %s\r",strMsg,pVerValue);
//原始文件名
strSubBlock.Format("\\StringFileInfo\\%s\\OriginalFileName",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s原始文件名: %s\r",strMsg,pVerValue);
//产品名称
strSubBlock.Format("\\StringFileInfo\\%s\\ProductName",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s 产品名称: %s\r",strMsg,pVerValue);
//产品版本
strSubBlock.Format("\\StringFileInfo\\%s\\ProductVersion",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s 产品版本: %s\r",strMsg,pVerValue);
//版权
strSubBlock.Format("\\StringFileInfo\\%s\\LegalCopyright",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s 版权: %s\r",strMsg,pVerValue);
//公司名
strSubBlock.Format("\\StringFileInfo\\%s\\CompanyName",strTranslation);
VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strMsg.Format("%s 公司名: %s\r",strMsg,pVerValue);
AfxMessageBox(strMsg);
free(pBlock);
return TRUE;
}
获取执行程序各种属性
最新推荐文章于 2022-03-15 21:01:21 发布