Subversion Repositories DevTools

Rev

Rev 2265 | Blame | Compare with Previous | Last modification | View Log | RSS feed

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "About.h"
//#include "Splash.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TAboutForm *AboutForm;
//---------------------------------------------------------------------------
__fastcall TAboutForm::TAboutForm(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::FormShow(TObject *Sender)
{
    char *ExeName = Application->ExeName.c_str();
    AnsiString versionString, buildString;
     DWORD infohandle = 0;
     DWORD infosize = ::GetFileVersionInfoSize(ExeName, &infohandle);
     if (infosize > 0)
     {
         char *infobuffer = (char *) malloc(infosize+1);

         GetFileVersionInfo(ExeName, 0, infosize, infobuffer);
         void            *pValue = NULL;
         unsigned int    pLen = 0;

         if ( ::VerQueryValue(infobuffer, "\\", &pValue, &pLen) )
         {
             VS_FIXEDFILEINFO *s = (VS_FIXEDFILEINFO *)pValue;

             int major = HIWORD(s->dwFileVersionMS);
             int minor = LOWORD(s->dwFileVersionMS);
             int patch = HIWORD(s->dwFileVersionLS);
             int build = LOWORD(s->dwFileVersionLS);
             
             buildString = "";
             if (build>0 ) buildString.sprintf("  Build %d",build); //pre-release
                    
             versionString.sprintf("Version %d.%d.%d", major, minor, patch);                          
         }
         else versionString.sprintf("Version unknown");
         
         free(infobuffer);
     }
     else versionString = Application->ExeName.c_str(); // fallback
    
    VersionLabel->Caption = versionString + buildString;
}
//---------------------------------------------------------------------------