title: How to check is there a process running with the given handle
body: <p>Scenario:
  From App1, I need to execute App2 passing App1.Handle as param.
  App2 should wait until App1's close. After this, App2 should replace App1.exe file with an updated version.</p>
  
  <ul>
  <li>Are there better ways to update a running executable file? </li>
  <li>If there aren't.. In App2, I know App1.Handle and I should check
  if App1 has been closed. How can this be verified starting from
  App1.Handle?</li>
  </ul>
  
  <p>EDIT:</p>
  
  <p>App1:</p>
  
  <pre><code>var
    ProcessHandle : THandle;
  begin
    ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, GetCurrentProcessId());
    //Is PROCESS_ALL_ACCESS needed?
    ShellExecute(0, 'open', 'App2.exe', PChar(IntToStr(ProcessHandle)), '.\', SW_SHOW);
  end;
  </code></pre>
  
  <p>App2:</p>
  
  <pre><code>var
    SenderHandle : THandle;
  begin
    if(ParamStr(1) &lt;&gt; '') then
    begin
      SenderHandle := StrToInt(ParamStr(1));
      WaitForSingleObject(SenderHandle, INFINITE);
      ShowMessage('App1 Terminated!');
      //Showmessage is executed when App1 is still running, what's wrong?
    end;
  end;
  </code></pre>