- Write your application using
main()
and all the GUI calls in there that you would have used inWinMain
. This will create an application with both a GUI and a console window. - Use the Windows SDK tool
editbin /SUBSYSTEM:WINDOWS appname.exe
to change the subsystem flag in the PE header, so Windows won't create a console window automatically. - If you want to have a working
stdout
for debug message or the like, you can either usefreopen
to directstdout
to a file, orAllocConsole
when you decide a console window is needed (for example, after an error occurs).
BTW: This thread indicates that the DMD compiler will prefer main()
over WinMain()
anyway if it finds both.