如何取得程序本身版本号
2008-03-08 12:45:51 来源:WEB开发网核心提示:String __fastcall TForm1::GetFileVersion(String FileName){int iVerInfoSize;char *pBuf;AnsiString asVer="";VS_FIXEDFILEINFO *pVsInfo;unsigned int iFile
String __fastcall TForm1::GetFileVersion(String FileName)
{
int iVerInfoSize;
char *pBuf;
AnsiString asVer="";
VS_FIXEDFILEINFO *pVsInfo;
unsigned int iFileInfoSize = sizeof( VS_FIXEDFILEINFO );
iVerInfoSize = GetFileVersionInfoSize(FileName.c_str(), NULL);
if(iVerInfoSize!= 0)
{
pBuf = new char[iVerInfoSize];
if(GetFileVersionInfo(FileName.c_str(),0, iVerInfoSize, pBuf ) )
{
if(VerQueryValue(pBuf, "\\",(void **)&pVsInfo,&iFileInfoSize))
{
asVer = IntToStr( HIWord(pVsInfo->dwFileVersionMS) )+".";
asVer += IntToStr( LOWORD(pVsInfo->dwFileVersionMS) )+".";
asVer += IntToStr( HIWORD(pVsInfo->dwFileVersionLS) )+".";
asVer += IntToStr( LOWORD(pVsInfo->dwFileVersionLS) );
}
}
delete pBuf;
}
return asVer;
}
更多精彩
赞助商链接