Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Minimize all opened windows of a selected process using C#

Posted on 2013-05-11
1
Medium Priority
?
1,977 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
jiangsheng earned 2000 total points
ID: 39159736
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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