Solved

Minimize all opened windows of a selected process using C#

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now