title: Retrieving the parent window Handle C# (trying to maximize outlook)
body: <p>I generally do run the method listed below to maximize iconized windows; 
  however when it comes to outlook, there are times where it will maximize a Mail (message) that i have open instead of the parent application (outlook) ; its just pulling up anything outlook that it finds and i need the parent, how can i achieve this?</p>
  
  <p>I have tried using WINAPI GetAncestor, I have also tried  GetParent  .</p>
  
  <pre><code>    public static bool EventChecking(string progr)
      {
          int bb = 0;
          if (Process.GetProcessesByName(progr).Length &gt; 0)
          {
              bb++;
          }
  
          if (bb == 0)
          {
              return false;
          }
  
          foreach (Process ddcd in Process.GetProcesses())
          {
              if (ddcd.ProcessName.Contains(progr))
              {
                  if (ddcd.MainWindowHandle != IntPtr.Zero)
                  {
                      pointer = ddcd.MainWindowHandle;
                      if (IsIconic(pointer))
                      {
                          SendMessage(pointer, 0x112, 0xF120, 0);
                      }
  
                      SetForegroundWindow(pointer);
                  }
              };
  
          }
          return true;
      }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I also recently tried:</p>
  
  <pre><code>if (ddcd.MainWindowTitle.EndsWith("- Outlook"))
  </code></pre>
  
  <p>and it still pulls up the single email</p>