I am evaluating madexcept and have perfect results in c++ applications up to now.
Now, I am trying to check usage in c++ DLLs, starting from the point that *the application itself will not be compiled with madexcept*, instead only the DLL (my DLL) will have madexcept embeddet.
After a bit of try-and-error and reading forum entries/delphi documentations, I found out that one approach is to make a try..catch wrapper in the dll, where some forum entries suggested different syntaxes.
1)
I now tested with three variants, can you *please* tell me if it doesn't care what variant I use or if there is a "suggested" or "better" variant?
Code: Select all
__try{
// call the real code
}
__except(EXCEPTION_EXECUTE_HANDLER){
Madexcept::HandleException();
};
Code: Select all
try{
// call the real code
}
catch (...)
Madexcept::HandleException();
};
Code: Select all
try{
// call the real code
}
catch (Exception &excObj){
Madexcept::HandleException(etNormal, &excObj);
};
2)
By using any of the three variants above, I can catch all exceptions in the "normal" call stack of the DLL code.
I seem not to be able to catch an exception thrown inside the GUI thread, though.
Example: I added a on button click event function, and inside that function I programmatically generate a division by zero exception.
When I click the button, the division by zero is catched by someone else (probably the main application), with a "simple" messagebox.
3)
And a last question, trying to solve issue #2 by myself I was wondering if it might help, in my DLL Entry Initialization routine, to (globally?) register the madexcept exception handler, so calling RegisterExceptionHandler() somehow.
I did not manage to do that, though, mostly because the example is in delphi and I did not manage to map that to c++ correctly, but even then, I am not even sure if this approach would help.
So I hope anybody can give me a hint into the right direction.
The task to be achieved is that I'd like to have all exceptions happening inside my DLL functions catched by madexcept, even tough the main application is not madexcept aware.
Thanks ahead for any hints!
Regards
Christoph