CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BCB3] Access to version numbering at runtime?



Robert Nilsen wrote:
> 
> I would like very much to use the project version numbering at runtime in my
> programs.  I would perhaps display this information in my AboutBox, etc...
> 
> Does anyone know how I can access this version info?
> 


I use this method in my About-Form:
( Note: FileVersion and LegalCopyright are TLabels on my form )


void __fastcall TAboutBox::FormCreate(TObject *Sender)
{
  String moduleFilename = Application->ExeName;
  unsigned long fvHandle;
  int infoSize;

  infoSize = GetFileVersionInfoSize (moduleFilename.c_str(), &fvHandle);

  if ( infoSize ) {
    char* buf = new char[infoSize];
    void* data;
    unsigned int size;

    GetFileVersionInfo (moduleFilename.c_str(), fvHandle, infoSize, buf);

    // Get the version number
    VerQueryValue (buf, "\\StringFileInfo\\040904E4\\FileVersion", &data, &size);
    FileVersion->Caption = Format (FileVersion->Caption, OPENARRAY(TVarRec, ((char*) data)));

    // Get the copyright string
    VerQueryValue (buf, "\\StringFileInfo\\040904E4\\LegalCopyright", &data, &size);
    LegalCopyright->Caption = (char*) data;

    delete [] buf;
  }
}


Hope that helps

-----
Mario

----------------------------------------------------------
Mario Zimmermann              email:      zimmerma@lion.de     
o.tel.o communications GmbH     web: http://www.o-tel-o.de
Universitaetsstr. 140         phone:   +49 (0)234 9709-315
D-44799 Bochum                  fax:   +49 (0)234 9709-111
----------------------------------------------------------


W Komornicki's Home Page | Main Index | Thread Index