[Lazarus] Version info

patspiper patspiper at gmail.com
Tue Sep 18 10:58:07 CEST 2012


On 18/09/12 10:21, michael.vancanneyt at wisa.be wrote:
>
> Yes.
> But as I wrote in another mail in this thread:
> I have a modified version of that unit that works for Linux as well; I 
> use it in production.
>
> Here is the relevant part for non-windows:
>
> uses resource, elfreader, versiontypes,versionresource;
>
>
> Type
>   TVersionQuad = Array[1..4] of Word;
>
> Function GetFileVersion (Const AFileName : string; Var Version : 
> TVersionQuad) : Boolean;
>
> Var
>   RS : TResources;
>   E : TElfResourceReader;
>   VR : TVersionResource;
>   I : Integer;
>
> begin
>   RS:=TResources.Create;
>   try
>     E:=TElfResourceReader.Create;
>     try
>       Rs.LoadFromFile(AFileName,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:=(VR<>Nil);
>     if Result then
>       For I:=1 to 4 do
>         Version[i]:=VR.FixedInfo.FileVersion[I-1];
>   Finally
>     RS.FRee;
>   end;
> end;
>
>
> Better yet would probably be to commit it in FPC SVN. I'll look into 
> that as
> well :-)

Your implementation of reading the file resources differs a little from 
Paul's 
(http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100723/8db6b97e/attachment.ksh). 
Are there any merits for each one?

Stephano




More information about the Lazarus mailing list