Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo

  How to let GUI application write output to commandline? (Tuesday, December 21, 2004)




Found the following interesting discussion in the Newsgroups:

How to let GUI application write output to commandline?
by: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


 Reply:
by:AlexS

 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








 
Previous Posts
    - Find the cursor position in a textbox
    - Extracting Image Metadata
    - NTFS Folder Permissions
    - To suspend the events
    - Get network status through WMI
    - Big red cross in DataGrid.. ?
    - Check Windows Services are still running OK
    - Monitor mouse events in application
    - Project deploy
    - Pull Non-VB.net program into focus and send keys.

Archives
    - 10/03/2004 - 10/10/2004
    - 10/10/2004 - 10/17/2004
    - 10/17/2004 - 10/24/2004
    - 10/24/2004 - 10/31/2004
    - 10/31/2004 - 11/07/2004
    - 11/21/2004 - 11/28/2004
    - 11/28/2004 - 12/05/2004
    - 12/05/2004 - 12/12/2004
    - 12/12/2004 - 12/19/2004
    - 12/19/2004 - 12/26/2004
    - 12/26/2004 - 01/02/2005
    - 01/23/2005 - 01/30/2005
    - 01/01/2006 - 01/08/2006
    - 09/24/2006 - 10/01/2006


Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland