procedure TMainFrm.DoOnException(Sender: TObject; E: Exception);
var
sInf:string;
begin
sInf:='发生异常,异常信息:'+#13+E.Message;
if Trim(sInf)<>'' then Application.MessageBox(PChar(sInf), '系统提示',
MB_OK+ MB_ICONWARNING)
end;
然后在MainForm的Create中加入
Application.OnException:=DoOnException;