#include "stdafx.h"
#include <Windows.h>
int main(int argc, char* argv[])
{
EXCEPTION_POINTERS *Seh;
__try
{
__try
{
__asm
{
xor eax,eax
mov [eax],0
}
}__finally
{
printf("这里执行了清理操作\r\n");
}
}__except(Seh = GetExceptionInformation(),EXCEPTION_EXECUTE_HANDLER)
{
printf("异常地址: %x\r\n",Seh->ExceptionRecord->ExceptionAddress);
}
printf("程序正常结束!\r\n");
return 0;
}
运行显示
这里执行了清理操作
异常地址: 40d795
程序正常结束!
这样搭配,我们就能既不让程序显示 一个不友好的信息框,又能保证程序正常运行,虽然有错误,但是其他功能模块不受影响