[2.0] Hide a console application

G

Guest

Hi, I have a console application and I would like to hide it when it's running.
Of course I took a look into the StartInfo property of the Process Class
(CreateNoWindow, WindowsStyle) but when I start my application, the dos
windows is still visible.

Process p = Process.GetCurrentProcess();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

This application is started by an other program which is not developped in
..NET so I can't create a ProcessStartInfo object and set CreateNoWindow and
WindowsStyle. Anyway I haven't source code.

Does someone have an idea or the solution for me ?

Thanks

Fred
 
B

Ben Voigt

Freddyboy said:
Hi, I have a console application and I would like to hide it when it's
running.
Of course I took a look into the StartInfo property of the Process Class
(CreateNoWindow, WindowsStyle) but when I start my application, the dos
windows is still visible.

If you don't need a console window, make it not a console application. A
Forms app isn't required to actually show a Form or run the event loop.
 
M

Michael D. Ober

Iterate through the process list and get your target process. Then use API
calls to get the window handle to the process and hide it.

Mike.
 
G

Guest

Thanks all for your answers.
In fact that's rigth I changed my console application to a "form
application" without start a "form" and my application works like I want.

Thanks

Best Regards

Fred
 

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