[Lazarus] Program version
Antonio Fortuny
a.fortuny at sitasoftware.lu
Wed Nov 6 16:07:02 CET 2013
Le 06/11/2013 15:46, Anton Kavalenka a écrit :
> Handle of EXE (hInstance) or .SO hMod:=Loadlibrary(dll_name);
Works fine on Win32 with *hInstance*: great ! 8-)
I guess it will run on Linux too
Thanks.
>
> regards,
> Anton
The code I use for Linux is the next one, which works almost the same
except that the source is a file:
function ReadVersionInfo(const sProgram: string; Out vv: String) :Boolean;
var
RS : TResources;
E : TElfResourceReader;
VR : TVersionResource;
I : Integer;
begin
Result := False; //no version info at all in the file
RS:=TResources.Create;
try
E:=TElfResourceReader.Create;
try
Rs.LoadFromFile(sProgram,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 begin
vv:= Format('%d.%d.%d.%d',[VR.FixedInfo.FileVersion[0],
VR.FixedInfo.FileVersion[1], VR.FixedInfo.FileVersion[2],
VR.FixedInfo.FileVersion[3]]);
End ;
Finally
RS.FRee;
end;
Question is: does an equivalent to the "T*Elf*ResourceReader" exist for
Windows executable files ?
I'm pretty sure that you do guess what I'm trying to do: have only one
fuction to retrieve the version of any program on any platform. If a
version using a file name can be setup, wonking on the current program
is easy: check on ParamStr(0).
Maybe a couple of [$IFDEF ...} will be needed but this is not an issue.
BTW, if the procedure works for WinCE too I'll be the happiest man on world.
If this piece of code could be helpfull to others, it could be
integrated to FPC or Lazarus, whatever.
It will need some rewriting though.
Antonio.
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
Sita Software
*Antonio Fortuny*
Senior Software engineer
220, avenue de la Liberté
L-4602 Niederkorn
Tel.: +352 58 00 93 - 93
www.sitasoftware.lu <http://www.sitasoftware.lu>
Your IT Partner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131106/6010defe/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: djbjhagh.jpg
Type: image/jpeg
Size: 2306 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131106/6010defe/attachment-0006.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dhihjhgh.jpg
Type: image/jpeg
Size: 921 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131106/6010defe/attachment-0007.jpg>
More information about the Lazarus
mailing list