Skip to content

Suppressing Windows crashes

Vladimir Panteleev edited this page Dec 7, 2014 · 3 revisions

Suppressing the standard "Program has stopped working" dialog on Windows

The following D program will launch another program with the general protection fault error dialog disabled.

import std.process;

extern(Windows) void SetErrorMode(int);
enum : uint { SEM_FAILCRITICALERRORS = 1, SEM_NOGPFAULTERRORBOX = 2 }

int main(string[] args)
{
	SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
	return spawnProcess(args[1..$]).wait();
}