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 ?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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!!!!!!!!!!!!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.