Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

console window out of a c# winapp

0 views
Skip to first unread message

Jürgen Seitz

unread,
May 29, 2002, 2:42:51 PM5/29/02
to
hello,

is it possible to create an additional console window from a WinApp compiled
with /winexe ?

thanx in advance
juergen seitz


Max[MS]

unread,
May 30, 2002, 7:50:29 AM5/30/02
to
Hello,

If you want to open a console application from Win32 application. Take a
look at System.Diagnostics.Process class.

Hope this helps.

Regards,
Max
==========================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
|From: "Jürgen Seitz" <jot....@t-online.de>
|Subject: console window out of a c# winapp
|Date: Wed, 29 May 2002 20:42:51 +0200

Jürgen Seitz

unread,
May 30, 2002, 11:17:11 AM5/30/02
to
thanx for your answer,
but i do not want to execute a console application, i only want to create a
console window where i can put some output.
Any idea ?

Jürgen Seitz


"Max[MS]" <m...@online.microsoft.com> schrieb im Newsbeitrag
news:xMMbgA9BCHA.2060@cpmsftngxa08...

nautonnier

unread,
May 30, 2002, 12:11:23 PM5/30/02
to
I'm amazed at how many times I've seen this question posed and yet *never*
answered. I would like to know if this possible myself.

"Jürgen Seitz" <jot....@t-online.de> wrote in message
news:#y3NWD0BCHA.1588@tkmsftngp02...

Max[MS]

unread,
May 31, 2002, 4:32:07 AM5/31/02
to
Hello,

In Windows, there're many APIs related console application such as
AllocConsole,AttachConsole. You can search console function in MSDN.

In .NET, you have to use PInvoke to call these APIs to create a console
window. There is a sample in MSDN,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/con
char_7g6r.asp for your reference.

Hope this helps.

Regards,
Max
==========================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
|From: "Jürgen Seitz" <jot....@t-online.de>

|References: <#y3NWD0BCHA.1588@tkmsftngp02> <xMMbgA9BCHA.2060@cpmsftngxa08>
|Subject: Re: console window out of a c# winapp

nautonnier

unread,
May 31, 2002, 11:38:39 AM5/31/02
to
That's great! Thanks NETMaster.


"NETMaster" <spam.ne...@swissonline.ch> wrote in message
news:eOh9giACCHA.2672@tkmsftngp05...
> To show a console from a GUI app is easy (PInvoke: AllocConsole)
> but for output with Console.Write there is some more interop needed:
>
> ok = AllocConsole();
> conOut = CreateFile( "CONOUT$", 0x40000000, 2, IntPtr.Zero, 3, 0,
IntPtr.Zero );
> ok = SetStdHandle( -11, conOut );
> Console.WriteLine( "Console ready!" );
>
> check sample attached!
> (Note, it does NOT restore the previous output!)
>
> MSDN:
> read 'remarks' for SetStdHandle
> http://msdn.microsoft.com/library/en-us/dllproc/conchar_7y79.asp
>
> KB Q90088 INFO: CreateFile() Using CONOUT$ or CONIN$
>
>
>
> --
> NETMaster (Thomas Scheidegger)
> http://www.cetus-links.org/oo_csharp.html
>
>
>
>
>
>
> "nautonnier" <OnTheLambFromAllThatSpam> wrote in message
news:uRw8vR$BCHA.2004@tkmsftngp02...


> > I'm amazed at how many times I've seen this question posed and yet
*never*
> > answered. I would like to know if this possible myself.
> > "Jürgen Seitz" <jot....@t-online.de> wrote in message
> > news:#y3NWD0BCHA.1588@tkmsftngp02...

William Stacey [MVP]

unread,
May 31, 2002, 6:29:10 PM5/31/02
to
What about the other way around?
1) Create a standard console app (so you can use the standard console.write
with no interop) 2) then fireup a form within the console app. There was an
example of this about 3-4 days ago.

--
William Stacey, MCSE
Microsoft MVP Windows 2000/NT Server

"NETMaster" <spam.ne...@swissonline.ch> wrote in message
news:eOh9giACCHA.2672@tkmsftngp05...
> To show a console from a GUI app is easy (PInvoke: AllocConsole)
> but for output with Console.Write there is some more interop needed:
>
> ok = AllocConsole();
> conOut = CreateFile( "CONOUT$", 0x40000000, 2, IntPtr.Zero, 3, 0,
IntPtr.Zero );
> ok = SetStdHandle( -11, conOut );
> Console.WriteLine( "Console ready!" );
>
> check sample attached!
> (Note, it does NOT restore the previous output!)
>
> MSDN:
> read 'remarks' for SetStdHandle
> http://msdn.microsoft.com/library/en-us/dllproc/conchar_7y79.asp
>
> KB Q90088 INFO: CreateFile() Using CONOUT$ or CONIN$
>
>
>
> --
> NETMaster (Thomas Scheidegger)
> http://www.cetus-links.org/oo_csharp.html
>
>
>
>
>
>
> "nautonnier" <OnTheLambFromAllThatSpam> wrote in message
news:uRw8vR$BCHA.2004@tkmsftngp02...

> > I'm amazed at how many times I've seen this question posed and yet
*never*
> > answered. I would like to know if this possible myself.
> > "Jürgen Seitz" <jot....@t-online.de> wrote in message
> > news:#y3NWD0BCHA.1588@tkmsftngp02...

Jason Hagar

unread,
May 31, 2002, 6:36:09 PM5/31/02
to
If you don't mind the Console window being open all of the time, right-click
your Project, click Properties, and then switch your project to a Console
Application. Or, if you use csc, use the option /t:exe

Jason

0 new messages