这种事件要写在Application.OnException中去截异常!!!!In addition to displaying the exception message, which happens by default, the following code shuts down the application when a VCL exception is not caught and handled.procedure TForm1.FormCreate(Sender: TObject); begin Application.OnException := AppException;end;procedure TForm1.AppException(Sender: TObject; E: Exception);begin Application.ShowException(E); Application.Terminate; end;
begin
Application.OnException := AppException;end;procedure TForm1.AppException(Sender: TObject; E: Exception);begin
Application.ShowException(E);
Application.Terminate;
end;