当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>C++基础入门教程

如何取得程序本身版本号

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

相关内容
赞助商链接