title: How to check if an handle should be closed?
body: <p>In case which ShellExecuteEx returns false, should the handle be closed?:</p>
  
  <pre><code>function EditAndWait(const AFileName : string) : boolean;
  var
    Info: TShellExecuteInfo;
  begin
    FillChar(Info, SizeOf(Info), 0);
    Info.cbSize := SizeOf(Info);
    Info.lpVerb := 'edit';
    Info.lpFile := PAnsiChar(AFileName);
    Info.nShow := SW_SHOW;
    Info.fMask := SEE_MASK_NOCLOSEPROCESS;
    Result := ShellExecuteEx(@Info);
    if(Result) then 
    begin
      WaitForSingleObject(Info.hProcess, Infinite);
      CloseHandle(Info.hProcess);
    end else
    begin
       //should I close the process handle?
    end;
  end;
  </code></pre>
  
  <p>More generally, how can I check if an handle should be closed?</p>