时间: 2021-07-31 作者:daque
application东西的onexception事变不妨捕获一切运用步调中未处置的缺点, 用一个自设置因变量重定向application.onexception,而后在该因变量中的e参数不妨归来运用步调缺点的东西,确定英文缺点代码能否包括在e.message确定能否用对应华文提醒包办。固然,不妨运用自设置的动静窗体表露。 procedure tform1.handleerror(sender: tobject; e: exception); begin if pos('can not link database',e.message)>0 then begin showmessage('不许贯穿数据库!'); //不妨用字设置窗体表露 exit; end; if pos('tcp/ip……',e.message)>0 then begin showmessage('搜集妨碍,不许贯穿数据库!'); //不妨用字设置窗体表露 exit; end; …… end; procedure tform1.formcreate(sender: tobject); begin application.onexception:=handleerror; end;