[Mono-devel-list] [PATCH] Detach console when executing IMAGE_SUBSYSTEM_WINDOWS_GUI on win32

Kornél Pál kornelpal at hotmail.com
Sat Jul 16 09:24:02 EDT 2005


The expected behaviour for a windowed application on Win32 is to have no
console unless you attach one either by calling AllocConsole or

The problem is that console will be attached when the application has
IMAGE_SUBSYSTEM_WINDOWS_CUI and no console will be attached when it has

As mono.exe is the executable it's flags are in effect. When it is a CUI
application the console window will be crated anyway and if it's detached it
will be flicker. This is looks lame but this is the best solution. Note that
the Win32 installer creates .bat files that are executing mono.exe so a
console window would be crated anyway.

If it were a GUI application a no console were attached by default so there
were no flickering console windows. AttachConsole could be used but it
requires Windows XP, 2003 or later. And cmd.exe for example will not wait
for the application if the console is not attached by the operating system
(CUI flag). AllocConsole creates a new console window so this is not a

The only proper solution could be to use two separate mono.exe files. One
for CUI and one for GUI. But this is too complicated and Windows is not the
primary platform for Mono so I think detaching the console for GUI
applications is the best solution.

Please review the patch.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: driver.c.diff
Type: application/octet-stream
Size: 566 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050716/2989ddd7/attachment.obj 

More information about the Mono-devel-list mailing list