0

In WPF(.net) I can use the following code to handle unexpected exceptions and exit my programm properly.

private void Application_Startup(object sender, StartupEventArgs e) {    
    this.DispatcherUnhandledException += App_DispatcherUnhandledException
}

private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) {
    // handle unhandled exception 
}

Is something like this availiable in VCL aswell? Or even in standard C++?

Knerd
  • 1,892
  • 3
  • 28
  • 55

1 Answers1

1

Have a look at the TApplication::OnException event (also the TApplicationEvents wrapper component), eg:

__fastcall TMainForm::TMainForm(TComponent *Owner)
    : TForm(Owner)
{
    Application->OnException = &AppException;
}

__fastcall TMainForm::~TMainForm()
{
    Application->OnException = NULL;
}

void __fastcall TMainForm::AppException(TObject *Sender, Exception *E)
{
    // handle unhandled exception 
}
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770