![]() |
Wie wirsam Exception abfangen
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. |
Re: Wie wirsam Exception abfangen
versuch mal die Funktion:
Delphi-Quellcode:
Das Handle ist dein Fensterhandle:
function DisplayPropDialog(const Handle: THandle; const FileName: string): Boolean;
var Info: TShellExecuteInfo; begin FillChar(Info, SizeOf(Info), #0); with Info do begin cbSize := SizeOf(Info); lpFile := PChar(FileName); nShow := SW_SHOW; fMask := SEE_MASK_INVOKEIDLIST; Wnd := Handle; lpVerb := cVerbProperties; end; Result := ShellExecuteEx(@Info); end;
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var filename : string; begin filename := 'C:\WINDOWS\system32\userinit.exe'; if not DisplayPropDialog(Handle, filename) then RaiseLastWin32Error; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:56 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz