欢迎大家讨论C++ Builder 开发环境是怎样捕捉到程序异常的。

我不懂电脑 2003-07-28 03:38:33
我们都知道在C++ Builder 开发环境中运行程序发出的异常会首先被IDE捕获他是怎么做到的欢迎大家讨论
...全文
131 53 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
53 条回复
切换为时间正序
请发表友善的回复…
发表回复
guanshangming 2003-10-27
  • 打赏
  • 举报
回复
这是IDE捕获错误的机制还是WINDOWS捕获错误的机制,只要安装个全局钩子监控WINDOWS的错误信息,过滤掉不需要的信息,然后提示不就可以了,事实上IDE出错提示与WINDOWS的没什么两样,另外,在WIN98下,不管有没有打开BC,一个程序执行了非法操作,还是给BC给拦截了,替换出错提示时多了个“调试”,说明WINDOWS的错误处理的DLL文件在安装BC时已经替换掉了。softice在拦截方面不是做得也很好吗?

一家之言,随便说说。
HenryGo 2003-10-25
  • 打赏
  • 举报
回复
好贴,收藏先
hnhhcj 2003-10-22
  • 打赏
  • 举报
回复
up
RomanticProgrammer 2003-10-22
  • 打赏
  • 举报
回复
我还是认为关键是这个API:UnhandledExceptionFilter

////////////////////////////////////////////////
The UnhandledExceptionFilter function passes unhandled exceptions to the debugger, if the process is being debugged. Otherwise, it optionally displays an Application Error message box and causes the exception handler to be executed. This function can be called only from within the filter expression of a try-except exception handler.

LONG UnhandledExceptionFilter(

STRUCT _EXCEPTION_POINTERS *ExceptionInfo // address of exception info
);


Parameters

ExceptionInfo

Points to an EXCEPTION_POINTERS structure containing a description of the exception and the processor context at the time of the exception. This pointer is the return value of a call to the GetExceptionInformation function.



Return Values

The function returns one of the following values:

Value Meaning
EXCEPTION_CONTINUE_SEARCH The process is being debugged, so the exception should be passed (as second chance) to the application's debugger.
EXCEPTION_EXECUTE_HANDLER If the SEM_NOGPFAULTERRORBOX flag was specified in a previous call to SetErrorMode, no Application Error message box is displayed. The function returns control to the exception handler, which is free to take any appropriate action.


Remarks

If the process is not being debugged, the function displays an Application Error message box, depending on the current error mode. The default behavior is to display the dialog box, but this can be disabled by specifying SEM_NOGPFAULTERRORBOX in a call to the SetErrorMode function.
The system uses UnhandledExceptionFilter internally to handle exceptions that occur during process and thread creation.
RomanticProgrammer 2003-10-22
  • 打赏
  • 举报
回复
怎么离题万里了啊。!!

~_~
jiangchun_xn 2003-10-21
  • 打赏
  • 举报
回复
Exception的构造函数钩子?
lihongxing2002 2003-10-21
  • 打赏
  • 举报
回复
学习学习再学习!
cyactive 2003-10-18
  • 打赏
  • 举报
回复
实际上没用想得太复杂,我们是做应用层
用try catch 就可以了
不过要研究Exception类及不同的情况下的Exception的子类
yjy1001 2003-10-18
  • 打赏
  • 举报
回复
我也来说两句,水平有限、且是个人见解,如有误 吾骂
bcb与delphi都通过try来捕捉程序异常
try
{
}
catch(Exception &E)
{

}
在try的时候,将try入口入栈,然后对try中的代码进行操作测试,如果测试汇报异常 即将地址出栈,然后跳入catch中,如果不则继续测试下一个代码,直到try结构完毕;然后清楚栈。

具体的代码操作测试过程不清


huangjuliang 2003-10-16
  • 打赏
  • 举报
回复
学习!~
我不懂电脑 2003-10-05
  • 打赏
  • 举报
回复
看来要结贴了。
wh_cd 2003-09-27
  • 打赏
  • 举报
回复
try
suxh666 2003-09-25
  • 打赏
  • 举报
回复
就是楼上说过的
try
{
code
}
catch(Exception &E)
{
AnsiString Name;
Name = E.ClassName();//异常
}
mlling 2003-08-14
  • 打赏
  • 举报
回复
关注!
oishi 2003-08-13
  • 打赏
  • 举报
回复
學習
mme 2003-08-13
  • 打赏
  • 举报
回复
IDE好像不能深入到系统里面去捕获异常.

我刚好线程出现异常,用CPU方式跟踪到API ExitThread里面,发现里面出了问题,

弹出了异常对话框,可是IDE并没有捕捉到,然后IDE就运行不下去了,说什么不可继续运行

错误.如果强行运行,就连IDE的什么DLL模块都出现错误,想关闭BCB都不行啦!
RomanticProgrammer 2003-08-12
  • 打赏
  • 举报
回复
////////////////////////////////////////////

力拔山兮气盖世
时不利兮骓不逝

////////////////////////////////////////////
Atomictry 2003-08-12
  • 打赏
  • 举报
回复
都赚钱去了。:(
我不懂电脑 2003-08-12
  • 打赏
  • 举报
回复
是呀:(
RomanticProgrammer 2003-08-11
  • 打赏
  • 举报
回复
怎么没有人关心这个问题。。

:(
加载更多回复(33)

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧