473,770 Members | 6,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4463
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.NETFramework SDKv1.1/cpguidenf/html/cpconbuildingco nsoleapplicat
ions.htm in Framework Help, or look for Console class.
Alternatively you can use Win32 API, like GetConsoleWindo w() 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*******@hotm ail.com> wrote in message
news:OM******** ******@tk2msftn gp13.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***********@ SPAMsympaticoPL EASE.ca> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi, Jason

you might want to check
ms-help://MS.NETFramework SDKv1.1/cpguidenf/html/cpconbuildingco nsoleapplicat ions.htm in Framework Help, or look for Console class.
Alternatively you can use Win32 API, like GetConsoleWindo w() 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*******@hotm ail.com> wrote in message
news:OM******** ******@tk2msftn gp13.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*******@hotm ail.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.co m>
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
5387
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 application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
11
4855
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. The problem is that ok is set to true, con is set to a number (all fine until here) the console window appears but the string "anthonyb" is never displayed there...
17
4235
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 console using System.Console.WriteLine if thge project has its "Output Type" to "Windows Application". However I can write to stdio if i set output type to "Console Application". When I do this I unfortunately get a "console box" as well
0
4705
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 message so that when the console window gets redrawn, I can repaint what I need to on this window. So far, no luck. First I install the hook by calling the SetWindowsHookEx passing the type WH_CALLWNDPROC, a delegate for the HOOKPROC param,...
6
6203
by: Mythran | last post by:
Is it possible to attach Windows WndProc hooks into a Console application window? Thanks, Mythran
10
6349
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 so that the window for the Console application is not visible. However, when using some of the 'advanced' properties of the StartInfo object, like Username, Password and Domain, the WindowsStyle property of the StartInfo object is ignored....
3
13860
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 application is run in Debug mode. However, I just can't get that to work. I'm using Visual Studio 2005. I've confirmed that my application is compiled as a console application, and that I'm running in Debug mode. To investigate this issue, I've reduced...
12
6543
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 combination to hide the console window at launch time. The application (for legacy reasons) hangs around by waiting on an old- fashioned Console.ReadLine() statement.
13
2847
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. probably suggest c/c++, which version. any suggestions greatly appreciated. -- soler
5
10776
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 server. Now, every console program instance will open a command mode window and they occupy the whole screen. I want to minimize all of them and maximize it if neccessary by manual. Is it possible and how to do it? I'm using VB.NET 2005. ...
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10001
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9867
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.