2011/10/31

取得檔案的版本資訊 file version information


int   iVerInfoSize;
char   *pBuf;
AnsiString   asVer;
VS_FIXEDFILEINFO   *pVsInfo;
unsigned   int   iFileInfoSize   =   sizeof(   VS_FIXEDFILEINFO   );

iVerInfoSize   =   GetFileVersionInfoSize(Application->ExeName.c_str(), NULL);
if(iVerInfoSize!=   0)
{
pBuf   =   new   char[iVerInfoSize];
if(GetFileVersionInfo(Application->ExeName.c_str(),0, iVerInfoSize, pBuf   )   )
{
if(VerQueryValue(pBuf, L"\\",(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;
}

沒有留言: