Get the version of your application as defined in the Delphi's IDE  

Send By: Q3 Team
Web : www.q3.nu
Email: dlib@q3.nu
Date: 21/01/00

Tip accessed 1273 times

 


In the Delphi's IDE, in Project->Options->VersionInfo, we can define the versión of our application.
How cap we capture it in runtime to show in a 'About Box' ?

With this function:


 procedure TForm1.Button1Click(Sender: TObject);

   function  GetAppVersion:string;
   var
    Size, Size2: DWord;
    Pt, Pt2: Pointer;
   begin
     Size := GetFileVersionInfoSize(PChar (ParamStr (0)), Size2);
     if Size > 0 then
     begin
       GetMem (Pt, Size);
       try
          GetFileVersionInfo (PChar (ParamStr (0)), 0, Size, Pt);
          VerQueryValue (Pt, '\', Pt2, Size2);
          with TVSFixedFileInfo (Pt2^) do
          begin
            Result:= ' Ver '+
                     IntToStr (HiWord (dwFileVersionMS)) + '.' +
                     IntToStr (LoWord (dwFileVersionMS)) + '.' +
                     IntToStr (HiWord (dwFileVersionLS)) + '.' +
                     IntToStr (LoWord (dwFileVersionLS));
         end;
       finally
         FreeMem (Pt);
       end;
     end;
   end;

 begin
   Form1.Caption:=Form1.Caption+GetAppVersion;
 end;