• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

Hook Abnormal Termination Popup Window

I want to change the default behavior when a not catched excection occurs in my program.
Today an abnormal termination program window popups.
My applicaiton is a MFC C++ application.

I try with SetUnhandledExceptionFilter and it works but not for all type of exception.
For example a throw not catched is not handle by this hook.

I try with _set_se_translator, set_terminate and set_unexpected but the same.

What i need is to change default behaviour of ANY uncatched exceptoin of ANY thread of my application.

Is this possible ?


  • 2
  • 2
1 Solution
In your InitInstance do this call:


Application will be terminated without popup.
eric3333Author Commented:
Does not work.
Uncatched exception still show abnormal termination window.

For example if i do :
throw new CException();
without handler the abnormal dialog box is displayed :(
Try this solution:

Define a function like the following:

LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
      AfxMessageBox( "Handled" );

      exit( 0 ); // or do something else (see SetUnhandledExceptionFilter() documentation for more informations)

At the begin of your InitInstance ( before to throw your exception) add the following line:

      SetUnhandledExceptionFilter( MyUnhandledExceptionFilter );

!!!!!! MyUnhandledExceptionFilter  will catch the exception only if the debuf is not active!!!!!!!!!!!!
eric3333Author Commented:
Arf. Good , near perfect but .....

I need to implement one handler for each thread.
This is ok but the problem is my program have a lot of threads and some are launched and managed by an api i cannot enter (i just have binary code).

Not perhaps now i just have to find a way to force the handler of all thread s....

Forced accept.

EE Admin
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now