Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-01

program version

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Antonio Fortuny

Hi folks.

First of all happy new year 2012.

Lazarus provides the possibility to include the program version in the project options. I've the ability to extract it at runtime using the WIndows core functions GetFileVersionInfoSize, GetFileVersionInfo and VerQueryValue.
I would like to know if there is an equivalent in Linux systems.

Antonio.

Reply by email

Sven Barth
to Antonio Fortuny
Antonio Fortuny wrote 9 lines
Hi folks. First of all happy new year 2012. Lazarus provides the possibility to include the program version in the project options. I've the ability to extract it at runtime using the WIndows core functions GetFileVersionInfoSize, GetFileVersionInfo and VerQueryValue. I would like to know if there is an equivalent in Linux systems.

The units related to the resource system are in
$fpcdir/packages/fcl-res/src. There's also a VersionResource unit.

For an example you can look at
$lazarusdir/examples/lazresexplorer/remainunit.pas where this is used.

I haven't tested either of them (the unit and the resource explorer), but they should provide you with a starting point.

Regards,
Sven

Reply by email

Unknown author
to Antonio Fortuny: Hi folks. First of all happy new year 2012. Lazarus provides the possibility to include…
Antonio Fortuny wrote 9 lines
Hi folks. First of all happy new year 2012. Lazarus provides the possibility to include the program version in the project options. I've the ability to extract it at runtime using the WIndows core functions GetFileVersionInfoSize, GetFileVersionInfo and VerQueryValue. I would like to know if there is an equivalent in Linux systems.

Yes. I use this code:

uses sysutils,resource, elfreader, versiontypes,versionresource;
Function GetProgramVersion (Out Version : String) : Boolean;
Var
   RS : TResources;
   E : TElfResourceReader;
   VR : TVersionResource;
   I : Integer;
begin
   Version:='';
   RS:=TResources.Create;
   try
     E:=TElfResourceReader.Create;
     try
       Rs.LoadFromFile(ParamStr(0),E);
     finally
       E.Free;
     end;
     VR:=Nil;
     I:=0;
     While (VR=Nil) and (I<RS.Count) do
       begin
       if RS.Items[i] is TVersionResource then
          VR:=TVersionResource(RS.Items[i]);
       Inc(I);
       end;
     Result:=(VRNil);
     if Result then
       For I:=0 to 3 do
         begin
         If (Version'') then
           Version:=Version+'.';
         Version:=Version+IntToStr(VR.FixedInfo.FileVersion[I]);
         end;
   Finally
     RS.FRee;
   end;
end;

Michael.

Reply by email

Antonio Fortuny
to Antonio Fortuny: Hi folks. First of all happy new year 2012. Lazarus provides the possibility to include…

Thanks to you both.
Useful and it works perfecly.

Thanks again.

Antonio.

Le 02/01/2012 10:06, Antonio Fortuny a ?crit :

Show quoted text 20 lines
Hi folks. First of all happy new year 2012. Lazarus provides the possibility to include the program version in the project options. I've the ability to extract it at runtime using the WIndows core functions GetFileVersionInfoSize, GetFileVersionInfo and VerQueryValue. I would like to know if there is an equivalent in Linux systems. Antonio. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email