你将Application.OnException替换掉就可以了。不过你替换后要仔细处理各个异常,
不然程序出错,你还不知道。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, ExtCtrls, DBCtrls, Mask;
type
TForm1 = class(TForm)
Button1: TButton;
Table1: TTable;
DBEdit1: TDBEdit;
DataSource1: TDataSource;
DBNavigator1: TDBNavigator;
Database1: TDatabase;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure MyPorcprocedure (Sender: TObject; E: Exception);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
application.OnException:=MyPorcprocedure;
try
table1.Post;
except
application.HandleException(Self);
end;
end;
procedure TForm1.MyPorcprocedure (Sender: TObject; E: Exception);
begin
ShowMessage('This is my execption handler');
end;
end.