473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Console in Windows Application

Hi,

How to add a console window to a Windows application?

Thank you very much in advance,

Pengyu
Nov 15 '05 #1
5 8697
Pengyu wrote:
Hi,

How to add a console window to a Windows application?

Thank you very much in advance,

Pengyu


What do you want to do with the console window? Do you merely want to
provide a command prompt? If so, then you can do this:

Process.Start("cmd.exe");

If you want to communicate between the command prompt and the .NET GUI
application then you'll have a lot more work to do. Without knowing what you
want to do I cannot say any more.

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)
Nov 15 '05 #2
I want my .NET GUI program has a window for Console and can communicate with
the Console.

Thank you very much!

Pengyu

"Richard Grimes [MVP]" <read my sig> wrote in message
news:es****************@TK2MSFTNGP10.phx.gbl...
Pengyu wrote:
Hi,

How to add a console window to a Windows application?

Thank you very much in advance,

Pengyu
What do you want to do with the console window? Do you merely want to
provide a command prompt? If so, then you can do this:

Process.Start("cmd.exe");

If you want to communicate between the command prompt and the .NET GUI
application then you'll have a lot more work to do. Without knowing what

you want to do I cannot say any more.

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)

Nov 15 '05 #3
Do something like this (not tested):
ProccessInfo pi = new ProccessInfo("cmd.exe");
pi.RedirectStandardError=true;
pi.RedirectStandardInput=true;
pi.RedirectStandardOutput=true;
Process cmd = Process.Start(pi);
cmd.StandardInput.WriteLine("Dir");
MessageBox.Show(cmd.StandardOutput.ReadToEnd());

Watch out for deadlocks, those method are blocking!


"Pengyu Hong" <ho**@stat.harvard.edu> wrote in message
news:eK****************@tk2msftngp13.phx.gbl...
I want my .NET GUI program has a window for Console and can communicate with the Console.

Thank you very much!

Pengyu

"Richard Grimes [MVP]" <read my sig> wrote in message
news:es****************@TK2MSFTNGP10.phx.gbl...
Pengyu wrote:
Hi,

How to add a console window to a Windows application?

Thank you very much in advance,

Pengyu


What do you want to do with the console window? Do you merely want to
provide a command prompt? If so, then you can do this:

Process.Start("cmd.exe");

If you want to communicate between the command prompt and the .NET GUI
application then you'll have a lot more work to do. Without knowing what

you
want to do I cannot say any more.

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)


Nov 15 '05 #4
Try "AttachConsole" API.

-vJ

"Pengyu Hong" <ho**@stat.harvard.edu> wrote in message
news:eK****************@tk2msftngp13.phx.gbl...
I want my .NET GUI program has a window for Console and can communicate with the Console.

Thank you very much!

Pengyu

"Richard Grimes [MVP]" <read my sig> wrote in message
news:es****************@TK2MSFTNGP10.phx.gbl...
Pengyu wrote:
Hi,

How to add a console window to a Windows application?

Thank you very much in advance,

Pengyu


What do you want to do with the console window? Do you merely want to
provide a command prompt? If so, then you can do this:

Process.Start("cmd.exe");

If you want to communicate between the command prompt and the .NET GUI
application then you'll have a lot more work to do. Without knowing what

you
want to do I cannot say any more.

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)


Nov 15 '05 #5
These may be useful:
http://www.codeproject.com/csharp/winconsole.asp
http://www.c-sharpcorner.com/Code/20...SysConsole.asp

--
William Stacey, MVP

"Pengyu Hong" <ho**@stat.harvard.edu> wrote in message
news:eK**************@tk2msftngp13.phx.gbl...
I want my .NET GUI program has a window for Console and can communicate with the Console.

Thank you very much!

Pengyu

"Richard Grimes [MVP]" <read my sig> wrote in message
news:es****************@TK2MSFTNGP10.phx.gbl...
Pengyu wrote:
Hi,

How to add a console window to a Windows application?

Thank you very much in advance,

Pengyu


What do you want to do with the console window? Do you merely want to
provide a command prompt? If so, then you can do this:

Process.Start("cmd.exe");

If you want to communicate between the command prompt and the .NET GUI
application then you'll have a lot more work to do. Without knowing what

you
want to do I cannot say any more.

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)


Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
2
by: Chris | last post by:
Hi, Currently, I have a console application written in C# and an unmanaged legacy DLL written in VC++ 6.0. In the DLL's previous application, when an event occurs in the DLL, a windows message...
1
by: James Carnley | last post by:
I am learning how to use windows forms and I have come across a small problem. Whenever I run my program it opens a console window before launching the windows form. The console doesnt go away...
6
by: Mark Allison | last post by:
Hi, I have an application that I want to be to run in Console mode and GUI mode. If no params are entered, I want the GUI fired up, if params are entered, then go into console mode. I believe...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
3
by: inpreet | last post by:
I am trying to build a console application in C#.Net. This application is suppose to run in background without user interaction. How can I hide console to appear?
1
by: lavu | last post by:
I currently have a C# windows Application . I would like this App to work through an command line interface also. I would like to specify command line params, which should start the app and process...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.