How to let GUI application write output to commandline?

  • Thread starter Thread starter Rvo
  • Start date Start date
R

Rvo

I'm writing an application that should work both as a GUI and a commandline
program.
When running from commandline I want to give all output to the commandline
instead of showing it it an own interface.
When I use Console.writeline the output doesn't appear at the commandline
prompt though.
I guess this is because the default output for the Console.Writeline is set
to the (invisible) gui at that time.

Is there a way to avoid/change this behaviour?

Thanks for your time...

Romain
 
Hi, Rvo

You have to detect if program is started in GUI or console mode and act
accordingly. If you want to duplicate output to console always, you might
want to consider
- creating your application as console one
- attach console to process otherwise using Win32 APIs like AttachConsole or
GetConsoleWindow. Depends how exactly you need console to behave

You might want to check Platform SDK help - Console Functions - to find more
details.

HTH
Alex
 
Back
Top