Skip to content

Suppressing DMD crashes

Vladimir Panteleev edited this page Feb 1, 2014 · 2 revisions

Suppressing DMD's "abnormal program termination" message box on Windows

Run the following D program in the background. It's not a perfect solution (message boxes will steal focus for a fraction of a second), but it'll keep the reduction going.

import std.c.windows.windows;

extern(Windows)
{
	HWND FindWindowA(LPCSTR, LPCSTR);
	HWND FindWindowExA(HWND, HWND, LPCSTR, LPCSTR);
}

void main()
{
	while(true)
	{
		auto h = FindWindowA("#32770", null);
		while (h)
		{
			auto h2 = FindWindowExA(h, null, null, "\nabnormal program termination\n");
			if (h2)
			{
				h2 = FindWindowExA(h, null, "Button", "OK");
				if (h2)
					SendMessageA(h2, BM_CLICK, 0, 0);
			}
			h = FindWindowExA(null, h, "#32770", null);
		}

		Sleep(1);
	}
}