Tuesday, September 05, 2006

Annoying Windows Behavior

You cannot create an executable in Visual Studio both inherits its parents standard in/out handles so that it can write to the console if run from a console. If you create a console application, it will inherit from its parent, but it will always create a console window even if not run from a command line.

So, say you would like to create a windows GUI application that you want to be able to pass command line parameters to. This works fine, but imagine you would like to print out a usage message to current console window if parameter is set.