My company has a large Windows application with a document-object model: open application, open a file, make some changes, save, close. I'm attempting to cut the GUI off of the top and create a console application that accepts some parameters, opens a file, does something useful, saves, closes the file, and terminates. Because there is a large amount of legacy code, I'm forced to use VCL forms application and launch it from the command line (or batch script). I really need to be able to print to stdout so I can write out status messages, respond to options like "--version" and "-?". I've spent all morning doing Google searches on this topic and I haven't found anything that's helpful.
The application is written in CodeGear C++ Builder 2007 using the VCL.
You can write to STDOUT in a GUI program, there just usually won't be any output since there is no Console, unless it is launched from an actual Console. Alternatively, look at the GetStdHandle()
and WriteConsole()
functions in the Win32 API. If GetStdHandle()
returns a valid handle, then you can write to it. This is particlarly useful if your GUI app is launched by another app that wants to intercept your STDOUT output for its own purposes.