PC Review


Reply
Thread Tools Rate Thread

Console Window

 
 
Jason Callas
Guest
Posts: n/a
 
      18th May 2004
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


 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      18th May 2004
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.
 
Reply With Quote
 
AlexS
Guest
Posts: n/a
 
      18th May 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Jason Callas
Guest
Posts: n/a
 
      19th May 2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      19th May 2004
Jason Callas <(E-Mail Removed)> 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 - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system function doesn't show console window in Vista window servic LT Khoo Microsoft VC .NET 1 13th Aug 2008 09:03 AM
Console app with no window ssg31415926 Microsoft C# .NET 1 27th May 2008 08:33 PM
How to change _buffer_ size of console window (or can runas inherit console props)? Alex Blekhman Microsoft Windows 2000 CMD Promt 4 18th Mar 2005 09:07 AM
Console.Writeline hangs if user click into the console window Urs Eichmann Microsoft VB .NET 3 20th Jul 2004 06:48 AM
console window Maciej Pacu³a Microsoft Dot NET Framework 1 18th Jul 2003 08:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:34 AM.