// 注意,这是 C++ 程序,文件名为: SEH-test.cpp
#include "stdio.h"
void test()
{
int* p = 0x00000000; // pointer to NULL
__try
{
puts("in try");
__try
{
puts("in try");
// causes an access violation exception;
// 导致一个存储异常
*p = 13;
puts(" 这里不会被执行到 ");
}
__finally
{
puts("in finally");
}
puts(" 这里也不会被执行到 ");
}
__except(puts("in filter 1"), 0)
{
puts("in except 1");
}
}
void main()
{
puts("hello");
__try
{
test();
}
__except(puts("in filter 2"), 1)
{
puts("in except 2");
}
puts("world");
}
/*
hello
in try
in try
in filter 1
in filter 2
in finally
in except 2
world
Press any key to continue
*/
SEH-test.cpp
最新推荐文章于 2025-08-22 12:09:46 发布