I'm writing an application that can track a set of windows application errors.
According to my current understandings, I can use two methods.
[italic]1. Enumerate the desktop windows and check for the presence of the specified error message.
2. Set a system wide hook that fires an event on each window creation and check for the error message.[/italic]
The second method seems to be more efficient as the application can be idle when no window is being created and it will be notified at the time of creation itself, instead of checking in a timer.
So I decided to follow second method.
I successfully tracked the occurance of:
1. Error report dialog
2. Runtime Error (With title: "Microsoft Visual C++ Runtime Library")
3. Out of memory error message.
But i couldn't track the 4th one:
4. Application error ( Please see the screenshot below ).
Now i'll tell you how did I reproduce this error.
Please see the code below:
int *a = new int;
Write this code under the click event of any button. Build it in release mode and run it. [b]You will have to click that button more than once (count may vary)[/b] to reproduce the error.
My problem is that the [b]creation of this window cannot be hooked [/b]using the hooking mechanism. I used the [italic]WH_CBT hook which can hook the creation of all windows possible including buttons inside the dialog[/italic]. But if this error message is displayed, nothing happens! No events fired.
The creation of al other error messages can be tracked in this way.
However, I can track this window by enumerating all top level windows in a timer. But I think it will be heavy.
Another thing that surprised me is that [b]I can see this error message even when the system is locked![/b]
Do you have any idea on why this is happening?
I'll be grateful for your responses...