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)
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int SW_MINIMIZE = 6;
private const int SW_RESTORE = 9;
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?