Solved

Minimize all opened windows of a selected process using C#

Posted on 2013-05-11
1
1,790 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

770 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