On Tue, 18 Sep 2012, Antonio Fortuny wrote:

FPC and Lazarus WiKi do only talk about the compiled target, not how
to extract resource data from other files. Of course, they have to be
compiled with FPC.

The fileinfo unit in FPC has this ability.

Michael.
yep but only for Windows (and WinCE), not Linux as they call GetFileVersionInfoSizeA and GetFileVersionInfoSizeW in version.dll to read the resource data information

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 :-)

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to