WEB开发网
开发学院软件开发C++ 如何取得程序本身版本号 阅读

如何取得程序本身版本号

 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;
}

Tags:如何 取得 程序

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接