delphi 捕捉全局异常错误的方法

private
    { Private declarations }
  public
  procedure GlobalExceptionHandler(Sender: TObject; E: Exception);
    { Public declarations }
  end;proced
 
 
ure TForm1.FormCreate(Sender: TObject);

begin

Application.OnException := GlobalExceptionHandler;

end;

 

 

procedure TForm1.GlobalExceptionHandler(Sender: TObject; E: Exception);

begin

mmLog.Lines.Add(Sender.ClassName + ': ' + E.Message);

end;

posted @ 2019-08-29 14:36  KunSun  阅读(1329)  评论(0编辑  收藏  举报