I want to test "ProcessWndProcException" function which should catch unhandled MFC exceptions. So I need a simple example, which will generate an unhandled MFC exception. Googling did not help much, so maybe anyone have any ideas?
0
votes
I'd recommend searching StackOverflow for why MFC exceptions are happening. Use the code in question. :)
– soulsabr
In the question, there is pointed ProcessWndProcException(CException* e, const MSG* pMsg) function, which is actually the code!
– Slav
You cannot generate an "unhandled exception". You need to raise an exception and do it in code that doesn't have any exception frames installed other than the top-level unhandled exception filter.
– IInspectable
1 Answers
3
votes
You can just throw a CException
and not catch it anywhere.
Exception Processing has information about various functions provided by MFC to throw exceptions.
// Throw a CMemoryException
AfxThrowMemoryException();
Bonus Info: Exceptions: Throwing Exceptions from Your Own Functions