Einzelnen Beitrag anzeigen

marcos

Registriert seit: 6. Mai 2006
50 Beiträge
 
#1

Wie wirsam Exception abfangen

  Alt 16. Jan 2010, 12:06
Hallo,

ich habe ein Problem, dass meine Exe einfach verschwindet ohne irgendwelche Fehlermeldung.
Das merkwürdige daran: das habe ich nur auf einem PC bis jetzt festgestellt und nur bei einer Datei C:\WINDOWS\system32\userinit.exe.
Gibt es eine Möglichkeit den Fehler wirksam abzufangen? Kann jemand das Problem nachvollziehen?

Gruß
marcos

P.S.
MadExcept hilft nichts.


Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellApi;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    procedure ShowShellPropertiesDlg(const APath: string);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
   Edit1.Text := 'C:\WINDOWS\system32\userinit.exe';
   try
     ShowShellPropertiesDlg(Edit1.Text);
   except
      MessageBox(Handle, 'Exception', 'Test', 0);
   end;
end;


procedure TForm1.ShowShellPropertiesDlg(const APath: string);
var
  AExecInfo: ShellAPI.TShellExecuteinfo; // info passed to ShellExecuteEx
begin
  FillChar(AExecInfo, SizeOf(AExecInfo), 0);
  AExecInfo.cbSize := SizeOf(AExecInfo);
  AExecInfo.lpFile := PChar(APath);
  AExecInfo.lpVerb := 'properties';
  AExecInfo.fMask := ShellAPI.SEE_MASK_INVOKEIDLIST;
  ShellAPI.ShellExecuteEx(@AExecInfo); //<----------------- EXE weg!!!!
end;


end.
  Mit Zitat antworten Zitat