在某种情况下,程序发生异常时,我们需要进行一些操作,例如“重启应用程序”,“报告相关错误”等。这个时候,我们就需要拦截异常处理函数。主要用到的 API SetUnhandledExceptionFilter().
该函数的x相关说明如下:
LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
Parameters
-
lpTopLevelExceptionFilter
- 自定义的异常处理函数。
LONG WINAPI UnhandledExceptionFilter( struct _EXCEPTION_POINTERS* ExceptionInfo);
通过上述操作后,发生异常时就可以自己处理异常情况了。