[Lazarus] getting version info of active project from within a design time package

Bernd prof7bit at gmail.com
Fri Sep 28 19:56:00 CEST 2012


I need to read the version number of the currently active project in
my design time package. For this I have written the following code:

function TSettings.GetVersion: String;
var
  Res: TAbstractProjectResources;
  ResVer: TProjectVersionInfo;
begin
  Res := LazarusIDE.ActiveProject.Resources as TAbstractProjectResources;
  ResVer := Res.Resource[TProjectVersionInfo] as TProjectVersionInfo;
  Result := Format('%d.%d.%d.%d',  [ResVer.MajorVersionNr,
                                    ResVer.MinorVersionNr,
                                    ResVer.RevisionNr,
                                    ResVer.BuildNr]);
end;

It needs the unit W32VersionInfo which is in the package LCL. Now I
have noticed that when adding LCL as a depedency to my package I
cannot compile the IDE from a clean directory, obviously when using
IDE while IDE is not yet compiled seems to be not such a good idea. Is
there a better way to get the version number? I could not find any
other place to access it.

Bernd




More information about the Lazarus mailing list