Solved

Minimize all opened windows of a selected process using C#

Posted on 2013-05-11
1
1,835 Views
Last Modified: 2013-05-12
I'm using the following code to minimize selected process window using Process.MainWindowHandle.
public static void MinProcess(int PID)
{
	Process proc = Process.GetProcessById(PID);
	if (proc.ProcessName == string.Empty)
		return;

	ShowWindow(proc.MainWindowHandle, SW_MINIMIZE);
}

[DllImport("User32.DLL")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int SW_MINIMIZE = 6;
private const int SW_RESTORE = 9;

Open in new window

My problem is that this code will only minimize one of the opened windows of a selected process, for example: If Outlook is opened with several emails (1 window per email), the code will minimize only one of the windows.

What do I need to change/modify to minimize ALL windows of the selected process?
0
Comment
Question by:or1969
1 Comment
 
LVL 4

Accepted Solution

by:
jiangsheng earned 500 total points
ID: 39159736
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question