title: How can I recover a reference to a process that has been relaunched?
body: <p>Using Process.Start, I am starting various IE8 and Firefox (3.5) processes which I keep a Process instance for.</p>
  
  <p>A little while later in the application, I'll use the Process instances' MainWindowHandle property to target the window for use with some platform API functions via P/Invoke.</p>
  
  <p>However, both IE8 and Firefox will kill the <em>second</em> process I start, then restart it using the first. This means that my Process instance now refers to a closed process, and so HasExited is true and MainWindowHandle is equal to IntPtr.Zero.</p>
  
  <p>Here's an example of what happens (I'm using IE8 for this example):</p>
  
  <ul>
  <li>Process.Start is called with "iexplore.exe"</li>
  <li>Process starts and continues running</li>
  <li>Process.Start is called again with "iexplore.exe"</li>
  <li>First process continues running, but the second is killed immediately</li>
  <li>Another iexplore process is started (presumably by the first iexplore process).</li>
  <li>During this time, the user sees the second IE window only after the second process is killed and restarted.</li>
  </ul>
  
  <p>I understand why these browsers behave this way, but it does create a problem for me if I want to control the created process later on.</p>
  
  <p>Has anyone come across this problem before? How would you recommend getting a reference to the process back? I thought about using GetProcessesByName and iterating through their window titles, but unfortunately the titles may be the same as the first process launched.</p>
  
  <p><strong>Note:</strong> IE8 was the first version of IE to use process separation and so only IE8 behaves this way, I don't have this problem with IE7, unfortuantely I need IE8 support as well.</p>