如果软件中存在问题,而又没有相应的异常处理代码,该异常会最后交给一个默认的异常处理程序处理,系统最后会弹出一个异常对话框。
问题是:我希望自己能够处理这种没有异常处理代码的异常,那么我需要写一个异常处理代码,替换掉系统默认的异常处理程序。根据资料,有一个API函数SetUnhandleExceptionFilter可以实现上述的目的,但不知道怎么用,那位大侠用
过的给我指点一下好么。
另外,还有一个函数SetErrorMode函数,可以保证软件发生未处理异常的情况下不
弹出错误对话框,可是,我试了它各种参数好像都没有用啊。
问题是:我希望自己能够处理这种没有异常处理代码的异常,那么我需要写一个异常处理代码,替换掉系统默认的异常处理程序。根据资料,有一个API函数SetUnhandleExceptionFilter可以实现上述的目的,但不知道怎么用,那位大侠用
过的给我指点一下好么。
另外,还有一个函数SetErrorMode函数,可以保证软件发生未处理异常的情况下不
弹出错误对话框,可是,我试了它各种参数好像都没有用啊。
解决方案 »
- MFC界面上如何做 Add 按钮,让输入的几条记录形成列表样式
- 关于窗口中画刷问题
- 如何删除使用CxImage类显示的图片?
- 急救,请高手帮我看看关于vector问题
- 关于键盘钩子的问题!急 急 急
- 使用BT下载东西,怎样等BT任务下载完后,就关闭我的计算机,谁能给代码??
- 如何对Access数据库进行全字段的搜索??
- CWnd::UpdateData()是做什么用的?该在什么时候使用?
- 继续大散分!关于穿透需要身份验证HTTP代理服务器,kevin_qing及sungang()或有相关经验的大虾们请进!!
- 個位大俠幫幫忙,請問如何提取長的CComBSTR當中的幾個字符,並賦個另一個CComBSTR
- 数据库查询时类型转换问题,很苦恼!!
- 对系统十分了解的高手请进(会汇编的优先)
{
}
CATCH()
{
}
finally
{
}
{
}
CATCH()
{
}
finally
{
}你的代码放到try里,然后catch可能出现的错误
把错误处理的代码放到catch里面写finally可有可无,无论程序是否发生异常,finally里的代码都是肯定执行的^_^
The SetUnhandledExceptionFilter function lets an application supersede the top-level exception handler that Win32 places at the top of each thread and process. After calling this function, if an exception occurs in a process that is not being debugged, and the exception makes it to the Win32 unhandled exception filter, that filter will call the exception filter function specified by the lpTopLevelExceptionFilter parameter. LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter // exception filter function
);
ParameterslpTopLevelExceptionFilterSupplies the address of a top-level exception filter function that will be called whenever the UnhandledExceptionFilter function gets control, and the process is not being debugged. A value of NULL for this parameter specifies default handling within UnhandledExceptionFilter. The filter function has syntax congruent to that of UnhandledExceptionFilter: It takes a single parameter of type LPEXCEPTION_POINTERS, and returns a value of type LONG. The filter function should return one of the following values: Value Meaning
EXCEPTION_EXECUTE_HANDLER Return from UnhandledExceptionFilter and execute the associated exception handler. This usually results in process termination.
EXCEPTION_CONTINUE_EXECUTION Return from UnhandledExceptionFilter and continue execution from the point of the exception. Note that the filter function is free to modify the continuation state by modifying the exception information supplied through its LPEXCEPTION_POINTERS parameter.
EXCEPTION_CONTINUE_SEARCH Proceed with normal execution of UnhandledExceptionFilter . That means obeying the SetErrorMod flags, or invoking the Application Error pop-up message box.
Return ValuesThe SetUnhandledExceptionFilter function returns the address of the previous exception filter established with the function. A NULL return value means that there is no current top-level exception handler. ResIssuing SetUnhandledExceptionFilter replaces the existing top-level exception filter for all existing and all future threads in the calling process.
The exception handler specified by lpTopLevelExceptionFilter is executed in the context of the thread that caused the fault. This can affect the exception handler's ability to recover from certain exceptions, such as an invalid stack. See AlsoUnhandledExceptionFilter