www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to launch a Windows compiled exe without showing a console?

reply "Gary Willoughby" <dev nomad.so> writes:
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
Jan 11 2014
next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Saturday, 11 January 2014 at 15:13:45 UTC, Gary Willoughby 
wrote:
 box. How can i suppress the console?
Add -L/subsystem:windows to the dmd command line, that should do it.
Jan 11 2014
prev sibling parent reply "nazriel" <spam dzfl.pl> writes:
On Saturday, 11 January 2014 at 15:13:45 UTC, Gary Willoughby 
wrote:
 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
Tell the linker that application is PE GUI IIRC it was -L/subsystem:windows ?
Jan 11 2014
parent "Gary Willoughby" <dev nomad.so> writes:
Thanks all.
Jan 11 2014