//*************************************************************** // From the book "Win32 System Services: The Heart of Windows 98 // and Windows 2000" // by Marshall Brain // Published by Prentice Hall // // Copyright 1995, by Prentice Hall. // // This code catches an invalid pointer reference exception. //*************************************************************** // catch.cpp #include #include VOID main(VOID) { CHAR *ptr; // point the pointer to an // invalid address ptr=NULL; __try { // attempt to assign a value // to the location pointed // to by the pointer *ptr=5; } __except(EXCEPTION_EXECUTE_HANDLER) { // report the exception type cerr << "Caught exception code: 0x" << hex << GetExceptionCode() << endl; } }