473,403 Members | 2,338 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,403 software developers and data experts.

Console Window

I am trying to figure out how to create a console window but cannot figure
out how to do this. I know it can be done since the C# and VB console
template projects do this but I see no code on how this is done.

The only thing I can think of is that there is hidden code to spawn cmd.exe?
Then they somehow direct console.read and console.write calls to the spawned
process.

Any thoughts (and some sample code) would be greatly appreciated.

- Jason
Jul 21 '05 #1
4 4427
Jason,
I am trying to figure out how to create a console window but cannot figure
out how to do this. I know it can be done since the C# and VB console
template projects do this but I see no code on how this is done.


Windows creates the console window, if needed, when you run a console
application. There's no code needed in the application itself to do
this.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
Hi, Jason

you might want to check
ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconbuildingconsoleapplicat
ions.htm in Framework Help, or look for Console class.
Alternatively you can use Win32 API, like GetConsoleWindow() to attach
system console.
Platform SDK has also wealth of information on what is possible.

What exactly you want to achieve?

If you want just to open console window - compile application as console
application.

HTH
Alex

"Jason Callas" <Ja*******@hotmail.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
I am trying to figure out how to create a console window but cannot figure
out how to do this. I know it can be done since the C# and VB console
template projects do this but I see no code on how this is done.

The only thing I can think of is that there is hidden code to spawn cmd.exe? Then they somehow direct console.read and console.write calls to the spawned process.

Any thoughts (and some sample code) would be greatly appreciated.

- Jason

Jul 21 '05 #3
I am aware that you can just create a console application but that does not
work for my purposes.

I am writing a windows service that COULD be run as a standalone application
by passing a command-line argument. In that case (while in the IDE) I would
want a console window to be opened to handle input and output.

I'm guessing I could always just change the output type of the project to
Console while developing and change it back to Windows when I want to
release it.

- Jason

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi, Jason

you might want to check
ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconbuildingconsoleapplicat ions.htm in Framework Help, or look for Console class.
Alternatively you can use Win32 API, like GetConsoleWindow() to attach
system console.
Platform SDK has also wealth of information on what is possible.

What exactly you want to achieve?

If you want just to open console window - compile application as console
application.

HTH
Alex

"Jason Callas" <Ja*******@hotmail.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
I am trying to figure out how to create a console window but cannot figure out how to do this. I know it can be done since the C# and VB console
template projects do this but I see no code on how this is done.

The only thing I can think of is that there is hidden code to spawn

cmd.exe?
Then they somehow direct console.read and console.write calls to the

spawned
process.

Any thoughts (and some sample code) would be greatly appreciated.

- Jason


Jul 21 '05 #4
Jason Callas <Ja*******@hotmail.com> wrote:
I am aware that you can just create a console application but that does not
work for my purposes.

I am writing a windows service that COULD be run as a standalone application
by passing a command-line argument. In that case (while in the IDE) I would
want a console window to be opened to handle input and output.

I'm guessing I could always just change the output type of the project to
Console while developing and change it back to Windows when I want to
release it.


If you want to create a console optionally, you can use WinConsole:
http://www.codeproject.com/csharp/winconsole.asp

I believe there are a number of libraries like this available, so you
might want to shop around.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5

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...
11
by: objectref | last post by:
Hi to all, i have a window app and i want to display some info in a console window. I figured out (after a very long search...) how am i supposed to do it and i try using the following code. ...
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...
0
by: Mythran | last post by:
I can draw onto the console window where I want using a mixture of API calls and the System.Drawing namespace (.Net 1.1). I am trying to install hooks for the window to catch a resize or another...
6
by: Mythran | last post by:
Is it possible to attach Windows WndProc hooks into a Console application window? Thanks, Mythran
10
by: Stephany Young | last post by:
When one uses the System.Diagnostics.Process.Start method to launch a common or garden Console application, one can set the WindowStyle property of the StartInfo object to ProcessWindowStyle.Hidden...
3
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the...
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...
13
by: =?Utf-8?B?c29sZXI=?= | last post by:
need to write a simple app with console output and file i/o to be distributed to other machines. Is it possbile in c# without .net overhead, not sure if all machines Xp have .net installed. ...
5
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Dear all, I'd like to know if there is any method to minimize command mode window when a console program is running. In my case, there are several console programs which run periodically in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.