|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
[2.0] Hide a console applicationHi, 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 Unless your app starts the process, the window cannot be hidden.
-- Show quoteHTH, Kevin Spencer Microsoft MVP Chicken Salad Shooter http://unclechutney.blogspot.com A man, a plan, a canal, a palindrome that has.. oh, never mind. "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com... > 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 Thanks for your answer Kevin.
Show quote "Kevin Spencer" wrote: > Unless your app starts the process, the window cannot be hidden. > > -- > HTH, > > Kevin Spencer > Microsoft MVP > Chicken Salad Shooter > http://unclechutney.blogspot.com > > A man, a plan, a canal, a palindrome that has.. oh, never mind. > > "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message > news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com... > > 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 > > > 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. Show quote "Kevin Spencer" <spam@uce.gov> wrote in message news:eNG2QrE9GHA.4408@TK2MSFTNGP02.phx.gbl... > Unless your app starts the process, the window cannot be hidden. > > -- > HTH, > > Kevin Spencer > Microsoft MVP > Chicken Salad Shooter > http://unclechutney.blogspot.com > > A man, a plan, a canal, a palindrome that has.. oh, never mind. > > "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message > news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com... >> 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 > > Maybe you could build your application as a Windows Service instead?
http://msdn2.microsoft.com/en-us/library/zt39148a.aspx Show quote > 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 "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message If you don't need a console window, make it not a console application. A news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com... > 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. Forms app isn't required to actually show a Form or run the event loop. Show quote > > 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 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 Show quote "Ben Voigt" wrote: > "Freddyboy" <Freddy***@discussions.microsoft.com> wrote in message > news:6C3F47C6-EC69-491C-8F4E-B3CF2A49DB5F@microsoft.com... > > 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. > > > > > 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 > > > |
|||||||||||||||||||||||