Hello,
I get some exceptions when I read the file info from some applications and the method I am using is provided by Lazarus.
I use Lazarus 1.8.4 in Windows 10 Pro German.
My programming skills I would estimate between beginner and intermediate.
I programmed a little tool that reads all information (like copyright, version info, etc) from applications.
I used the following code example:
http://wiki.freepascal.org/Show_Application_Title,_Version,_and_CompanyI created a new project in Lazarus, added a button and for the Button1Click event I pasted some code from the WIKI article above.
Here is the complete source of my unit:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
fileinfo,
winpeimagereader; {need this for reading exe info}
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
FileVerInfo: TFileVersionInfo;
begin
FileVerInfo := TFileVersionInfo.Create(nil);
try
FileVerInfo.FileName := 'C:\lazarus\lazarus.exe';
FileVerInfo.ReadFileInfo;
ShowMessage(FileVerInfo.VersionStrings.Text);
finally
FileVerInfo.Free;
end;
end;
end.
This works perfectly for most applications.
But
some applications raise exceptions at the line
FileVerInfo.ReadFileInfo; (line 47).
Examples:
- C:\Program Files\FreeCommander XE\FreeCommander.exe
Exception Message: Cannot find resource: Type = 1, Name = 17, Lang ID = 0800)
- C:\Program Files (x86)\System Explorer\SystemExplorer.exe
Exception Message: Cannot find resource: Type = 1, Name = 12, Lang ID = 0000)
- D:\PortableApps\PortableApps\FirefoxPortable\App\Firefox\firefox.exe
Exception Message: Duplicate key '0'
- D:\PortableApps\PortableApps\_ToDoList\ToDoList.exe
Exception Message: Duplicate key 'oList'
As I wrote above I am not a good programmer.
But in
FileVerInfo.ReadFileInfo I see
no exception handling (the block "except").
Could that be the problem?
Is this a problem that can be fixed from your side (Lazarus Developers) or do I have to do anything?
I also can not set a breakpoint in FileVerInfo.ReadFileInfo to see what line causes the problems (the debugger does not stop, no matter where I set the breakpoint).
If you have any tips how I can make the breakpoint working, this would be fantastic.
I have in Lazarus the two additional packages
anchordockingdsgn and
sparta_DockedFormEditor.
I hope that this is not the reason for my problems (but I think not).
Thank you for your help!
Best regards
OLLI