windows try and except blocks
excuted in event of an error is placed in an __except block.
The EXCEPTION_EXECUTE_HANDLER constant in the __except block indicates that errors will be handled by the block and not passed to other handlers.
LRESULT CALLBACK WndProc(HWND hWnd,
UINT message, WPARAM wParam, LPARAM lParam)
{
__try
{
char* lpC = 0;
*lpC = 'A';
default:
return DefWindowProc(hWnd, message,
wParam, lParam);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
MessageBox(hWnd,
_T("Page Fault Caught in exception handling!"),
szTitle, MB_OK | MB_ICONEXCLAMATION);
}
} /* end WndProc */