{
cout << "caught c++ exception " << hex << exception << endl;
}
return 0;
}
运行它的话,这个控制台程序将导致如此一个windows messagebox:
它是由于一个未被捕获的seh异常传递到程序外面造成的。
现在,增加一个异常转换函数,并将visual c++运行库设为使用这个转换函数:
#include <iostream>
using namespace std;
#include "windows.h"
static void my_translator(unsigned code, exception_pointers *)
{
throw code;
}
int main()
{
_set_se_translator(my_translator);