Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing crash messages in Windows

Tags:

windows

crash

My application needs to scan 3rd party files that often leads to crash. In order to overcome that, it uses a separate process to scan those files and whenever this process crashes my application just instantiates another one.

My problem is that after each crash I get Windows crash message: "AuxScanner has stopped working..."

How can I prevent this message and crash quietly?

I'm using named pipes for inter-process communication.

Thanks

like image 246
kambi Avatar asked Jul 15 '11 14:07

kambi


2 Answers

See http://blogs.msdn.com/b/oldnewthing/archive/2004/07/27/198410.aspx: you can disable the program crash dialog (though you'll need to do so from inside the sub-process).

The way I read it, you want something like this in your sub-process:

#include <windows.h>

//...

SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
//or if you only care about Vista or newer:
//SetErrorMode(GetErrorMode() | SEM_NOGPFAULTERRORBOX);

Interesting question by the way - this might be interesting to stick into all kinds of software during development; it's quite annoying when your actively-developed code crashes (not unexpected), and then then everything waits, your UI changes focus, and it offers to (pointlessly) send a crash dump to microsoft...

like image 190
Eamon Nerbonne Avatar answered Oct 02 '22 19:10

Eamon Nerbonne


If you're getting the "...hast stopped working" message that means you didn't handle the exception. Make sure the sections of code that can or might be inducing the crash are wrapped in try/catch blocks and handle the exceptions gracefully.

like image 38
Mark W Avatar answered Oct 02 '22 19:10

Mark W