Skip to content

Suppressing Windows crashes

Vladimir Panteleev edited this page Feb 1, 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 spawnvp(P_WAIT, args[1], args[1..$]);
}