Qt:
#include<windows.h>
#include<winver.h>
///引入Version.lib库
QString InfomationCollect::GetFileVertion( QString fullName )
{
// 必须要用,不然无法获取到exe的版本信息
<span style="white-space:pre"> </span>#pragma comment(lib, "Version")
DWORD dwLen = 0;
char* lpData=NULL;
BOOL bSuccess = FALSE;
QString fileInfomation;
//获得文件基础信息
//--------------------------------------------------------
dwLen = GetFileVersionInfoSize(fullName.toStdWString().c_str(), 0);
if (0 == dwLen)
{
//qDebug()<<"Get file verstion error!";
return"";
}
lpData =new char [dwLen+1];
bSuccess = GetFileVersionInfo(fullName.toStdWString().c_str(), 0, dwLen, lpData);
if (!bSuccess)
{
//qDebug()<<"Get file verstion error!";
delete lpData;
return"";
}
LPVOID lpBuffer = NULL;
UINT uLen = 0;
//获得语言和代码页(language and code page)
//---------------------------------------------------
bSuccess = VerQueryValue(lpData,
(TEXT("\VarFileInfo\Translation")),
&lpBuffer,
&uLen);
QString strTranslation,str1,str2;
unsigned short int *p =(unsigned short int *)lpBuffer;
str1.setNum(*p,16);
str1="000"+ str1;
strTranslation+= str1.mid(str1.size()-4,4);
str2.setNum(*(++p),16);
str2="000"+ str2;
strTranslatio