This project showcases how a program can both run as a console project and as a Windows native application.
The program is just a Windows application in reality, but it calls AttachConsole() to get a hold of the current console and act as a valid Console Subsystem program.
AttachConsole() returns immediately so the trick to block the console is
to wrap the executable in a launcher script - mm.cmd here.
Open the .sln in Visual Studio and build it. To run either:
-
double click the resulting
Metamorph.exeto run it as a GUI application -
from a console, run the
mm.cmdscript in from theMetamorph.exeoutput directory. Redirects work across the different terminals as expected:.\mm.cmd foobar > .\foo.txt 2>&1