How to launch a Windows compiled exe without showing a console?

Gary Willoughby dev at nomad.so
Sat Jan 11 07:13:44 PST 2014


How to launch a Windows compiled exe without showing a console?

I've tried the following two ways and when i execute the 
resulting *.exe file a console is shown alongside the dialog box. 
How can i suppress the console?

import std.string;
import core.sys.windows.windows;

void main(string[] args)
{
	MessageBoxA(null, "Hello".toStringz(), "Error", MB_OK | 
MB_ICONEXCLAMATION);
}

and

import std.string;
import core.runtime;
import core.sys.windows.windows;

extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE 
hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	Runtime.initialize();

	MessageBoxA(null, "Hello".toStringz(), "Error", MB_OK | 
MB_ICONEXCLAMATION);

	Runtime.terminate();
	return 0;
}

Compiler flags: dmd -release source.d


More information about the Digitalmars-d-learn mailing list