title: Starting process and storing handle to window
body: <p>Would someone mind helping me out with a problem I've been stuck on for a bit? I'm using C# and trying to start a couple processes, and later move those windows to separate monitors.</p>
  
  <p>So far this was the main idea:</p>
  
  <pre><code>Process p1 = Process.Start(@"1.pptx");
  Process p2 = Process.Start(@"2.pptx");
  
  SetWindowPos(p1.MainWindowHandle, -1,
                          0,
                          0,
                         100,
                          100,
                          SWP_SHOWWINDOW);
  SetWindowPos(p2.MainWindowHandle, -1,
                          200,
                          200,
                         100,
                          100,
                          SWP_SHOWWINDOW);
  </code></pre>
  
  <p>But after trying a bunch of different things, I haven't been able to get it to work. Could anyone give me some pointers?</p>
  
  <p>As a side note which is confusing me, if I print those to process IDs (p1, p2), and then run this code:</p>
  
  <pre><code>Process[] processlist = Process.GetProcesses();
  
  foreach (Process process in processlist)
  {
         if (!String.IsNullOrEmpty(process.MainWindowTitle))
         {
              Console.WriteLine("Process: {0} ID: {1} Window title: {2}", process.ProcessName, process.Id, process.MainWindowTitle);
         }
  }
  </code></pre>
  
  <p>those process IDs don't exist. I know there must be something simple I'm missing...?</p>
  
  <p>UPDATE: The reason for the problem above is that for some reason the MainWindowTitle didn't have a value, so it wasn't printing the pid.</p>