static void RestartClientProgram() { char szClient[MAX_PATH]; GetModuleFileName(NULL, szClient, sizeof(szClient)); printf("Restarting %s\n", szClient); WinExec(szClient, SW_NORMAL); _exit(1); // Don't use exit() since may be trapped } static LONG WINAPI MyUnHandleExceptionFilter(struct _EXCEPTION_POINTERS *lpExceptionInfo) { int code; code = lpExceptionInfo->ExceptionRecord->ExceptionCode; printf("Exception code=0x%x\n", code); RestartClientProgram(); return EXCEPTION_EXECUTE_HANDLER; // Terminate probably } void ExampleUse() { SetUnhandledExceptionFilter(MyUnHandleExceptionFilter); }
Programming Tips - Win32: How do I do catch exceptions that are being thrown by a DLL
Date: 2008jul31
Keywords: CxxThrowException
OS: Windows
Platform: win32
Language: C/C++
Q. Win32: How do I do catch exceptions that are being thrown by a DLL
I don't have the source for?
A. Use SetUnhandledExceptionFilter() like this...