422,530 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,530 IT Pros & Developers. It's quick & easy.

How do I minimize my currently executing Console application?

P: n/a
GG
Is there a way to minimize my current console app?
Using this code but does not work

System.Diagnostics.Process
currentProcess=System.Diagnostics.Process.GetCurre ntProcess();

currentProcess.StartInfo.WindowStyle=System.Diagno stics.ProcessWindowSty
le.Minimized;
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try this test console application class, it will minimize the app, sleep two
seconds, then restore it.

using System;
using System.IO;

namespace ConsoleApplication1
{

class Class1
{

[System.Runtime.InteropServices.DllImport("user32.d ll")]
private static extern bool ShowWindow( IntPtr hWnd, int nCmdShow);
private const int SW_MINIMIZE = 6;
private const int SW_MAXIMIZE = 3;
private const int SW_RESTORE = 9;
[STAThread]
static void Main(string[] args)
{
IntPtr winHandle =
System.Diagnostics.Process.GetCurrentProcess().Mai nWindowHandle;
ShowWindow( winHandle, SW_MINIMIZE);
System.Threading.Thread.Sleep(2000);
ShowWindow( winHandle, SW_RESTORE);

}
}
}

"GG" <gg@hotmail.com> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
Is there a way to minimize my current console app?
Using this code but does not work

System.Diagnostics.Process
currentProcess=System.Diagnostics.Process.GetCurre ntProcess();

currentProcess.StartInfo.WindowStyle=System.Diagno stics.ProcessWindowSty
le.Minimized;
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2

P: n/a
GG
This is what I was exctaly looking for

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.