大家好:
在捕捉Delphi中的异常时,用try有些异常不能被捕获。我想请问大家,有什么办法可以捕获Delphi中的所有异常呢?请不吝赐教!
在捕捉Delphi中的异常时,用try有些异常不能被捕获。我想请问大家,有什么办法可以捕获Delphi中的所有异常呢?请不吝赐教!
解决方案 »
- 如何在fastreport里取得总共的页数(就是打印出来以后的页数,我以为totalpages,但是发现它总是0),顶者有分
- 求Delphi70架构版,下载完毕就给分,决不食言!!!!
- 分不多,但是肯定给!
- FastReport的问题,进来拿分!
- 怎么实现在delphi 中向SQL Server 附加数据库?
- 如何在QuickReport中的TQRDBText自动换行(很急的)
- DCOM中的IPicture应该怎样使用,客户怎么老是提示运行总提示“意外错误”,然后服务器异常退出
- *********还是相同的问题,请大家帮帮忙!***********
- 帮忙指点一下?
- 用新的DBEdit代替DBGrid中的编辑框后,如何控制焦点的移动?
- 关于不安装BDE而访问Paradox数据库的问题,使用网上大侠们介绍的方法,为什么不行?
- TDBEdit 控件无法输入小数点
Tools->Debug Options->Language Exceptions面板中把“Stop On Delphi Exceptions”
或将应用程序编译成可执行文件后运行
还有不能捕获的异常?
Application.OnException := ProcException;
procedure TCltForm.ProcException(Sender: TObject; E: Exception);
begin
if E is ESocketError then
//
else
Application.ShowException(E);
end;
Application.OnException:=SquirrelCode.useinfo.MyExceptionHandler;然后在
SquirrelCode单元下useinfo类中添加//全局错误处理
procedure TMainInfo.MyExceptionHandler(Sender: TObject;
EInstance: Exception);
Begin
//全局错误处理模块
If EInstance is EDivByZero then
begin
useinfo.SystemInfo:='错误,除数不能为零';
useinfo.SystemMoreInfo:='错误,除数不能为零';
application.CreateForm(TfrmShowMessage, frmShowMessage);
frmShowMessage.ShowModal;
end
else if EInstance is EAccessViolation then
begin
useinfo.SystemInfo:='错误,访问了无效的内存区域';
useinfo.SystemMoreInfo:='错误,访问了无效的内存区域';
application.CreateForm(TfrmShowMessage, frmShowMessage);
frmShowMessage.ShowModal;
end
else if (EInstance is EFOpenError) then
begin
useinfo.SystemInfo:='错误,文件不能打开';
useinfo.SystemMoreInfo:='错误,文件不能打开';
application.CreateForm(TfrmShowMessage, frmShowMessage);
frmShowMessage.ShowModal;
end
else if (EInstance is EConvertError) then
begin
useinfo.SystemInfo:='错误,非法的类型转换';
useinfo.SystemMoreInfo:='错误,非法的类型转换';
application.CreateForm(TfrmShowMessage, frmShowMessage);
frmShowMessage.ShowModal;
end
else
begin
useinfo.SystemInfo:='错误,'+EInstance.ClassName;
useinfo.SystemMoreInfo:='错误,'+#13+EInstance.ClassName+#13+EInstance.Message;
application.CreateForm(TfrmShowMessage, frmShowMessage);
frmShowMessage.ShowModal;
end;
end;
有的delphi自带的 TApplicationEvents 控件
On E:Exception do
begin
end;
end;
Exception是所有的异常。如果想让异常抛出来,就加raise;
请问一下啊,SquirrelCode单元是系统单元吗?还是你自己写的单元?
On E:Exception do
begin
ShowMessage(e.Message);
end;
end;
{ Private declarations }
public
{ Public declarations }
procedure TryExcepts(Sender: TObject; E: Exception);
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.TryExcepts(Sender: TObject; E: Exception);
begin
Edit1.Text := E.Message;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException := TryExcepts;
end;procedure TForm1.Button1Click(Sender: TObject);//测试 1
var
I : integer;
begin
I := StrToInt('a');
end;procedure TForm1.Button2Click(Sender: TObject);//测试2
var
I : integer;
S : TStringList;
begin
S := TStringList.Create;
S.Text := 'line1' + #10 + 'line2' + #10 +'line3' + #10 +'line4';
for I := 0 to 5 do
showmessage(S[I]);// 第5次循环时报 越界
S.Free;
end;
不好意思,最近公司不准上网了,所以很久都没来。Sorry!!
是在使用Indy的一个控件的时候出现的异常