title: C# How to minimize another application by a given process id?
body: <p>I would like to minimize an application by its process id. I have searched on SO and found the following code</p>
  
  <pre><code>private const int SW_MAXIMIZE = 3;
  private const int SW_MINIMIZE = 6;
  [DllImport("user32.dll", EntryPoint = "FindWindow")]
  public static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
  [DllImport("user32.dll")]
  [return: MarshalAs(UnmanagedType.Bool)]
  static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  
  public void MinimizeWindow()
  {
    IntPtr hwnd = FindWindowByCaption(IntPtr.Zero, "NotePad");
    ShowWindow(hwnd, SW_MINIMIZE);
  }
  </code></pre>
  
  <p>But I don't want to find window by caption because the caption for an app changes. I have a given process id that is coming from another module that request minimize the app with the given process id.</p>
  
  <p>Is there such a thing like this?</p>
  
  <pre><code>  public static extern IntPtr FindWindowByProcess(IntPtr ZeroOnly, int lpProcessID);
  </code></pre>
  
  <p>Or if not, anyway to go around?</p>