I need to catch Integer divide by zero and access violation reading or writing a protected memory and display my own dialog, and do something approprate. These exception can not be catched by try {} catch {} mechanism because hardware generates these exceptions. How can I catch there exceptions? Any suggestions or reference to related articles appreciated mr.abzadeh
See the documentation for __try
/ __except
mechanism.
This is used in Windows for catching hardware exceptions.
There is a very easy way to catch any kind of exception (division by zero, access violation, etc.) in Visual Studio using try -> catch (...) block :)
A minor project tweaking is enough. Just enable /EHa option in project settings. See Project Properties -> C/C++ -> Code Generation -> Modify the Enable C++ Exceptions to "Yes With SEH Exceptions". That's it!
See details here: http://msdn.microsoft.com/en-us/library/1deeycx5(v=vs.80).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With