如何取得措施自己版本号
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;
}