Window and console application all in one

G

Gionni

Hello everyone,
I'm have a window application, but it is a console application
too. I'll try to explain better: if I call the program without
parameters the GUI starts. Otherwise it runs as a console application.
In other words, I emulate the "certmgr" behavior.
My problem is I cannot display any trace in the console (Someghing
like: Pass 1: OK, Pass 2: etc). Console.Write does not work, because
the window application has not a console. Is there any method to show
redirect the input to the console? Please could you give me any
example?

Thanks all, Gionni
 
A

AlexS

Hi, Gionni

compile application as Console project. It will do the trick.
In Main check if arguments are present and act accordingly.

HTH
Alex
 
G

Gionni

AlexS said:
compile application as Console project. It will do the trick.
In Main check if arguments are present and act accordingly.

Thanks, I tested it and works.
Only one thing more. Is there any way to make the command prompt
disappear when I do a double click on my application?

Thanks again, Gionni
 
A

AlexS

Hi, Gionni

You can do this if you get console window handle and hide it using win32
API. Look for GetConsoleWindow and ShowWindow functions in platform SDK or
on MSDN. You need to get handle of console and do ShowWindow on it with
SW_HIDE parameter. Declarations for functions you can find on
www.pinvoke.net and on several other sites.

HTH
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top