[fpc-pascal] Reading exe version info on Linux?
Reinier Olislagers
reinierolislagers at gmail.com
Wed Mar 20 17:21:57 CET 2013
The program below works fine on Windows for reading e.g. info on
explorer.exe
It fails on Linux (FPC trunk x64, compiled 2013/03/14) when testing with
explorer.exe:
Going to read version resource for /tmp/explorer.exe
An unhandled exception occurred at $0000000000443607:
EResNotFound: Resource "1" not found
$0000000000443607
In a bug I raised, Michael van Canneyt indicated this error may be due
to the filename not being picked up.
However, the checking code seems to pick up the correct name.
What am I still doing wrong?
Thanks,
Reinier
program exeinfodemo; //not exeinfo, that's already a ppu
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
SysUtils, Classes,
fileinfo, winpeimagereader;
var
TargetFile: string;
WindowsExeInfo: TFileVersionInfo;
i: integer;
begin
TargetFile:=paramstr(1);
if TargetFile='' then
begin
writeln('No file specified, substituting c:\windows\explorer.exe');
TargetFile:='c:\windows\explorer.exe';
end;
if not(fileexists(TargetFile)) then
writeln('The file you specified does not exist. Aborting.')
else
writeln('Going to read version resource for ',TargetFile);
WindowsExeInfo := TFileVersionInfo.Create(nil);
try
WindowsExeInfo.FileName:=TargetFile;
WindowsExeInfo.ReadFileInfo;
for i:=0 to WindowsExeInfo.VersionStrings.Count-1 do
begin
writeln('Version string ',i,': ',WindowsExeInfo.VersionStrings[i]);
end;
finally
WindowsExeInfo.Free;
end;
end.
More information about the fpc-pascal
mailing list