title: Is there any problem to using this code in a Thread ? (Delphi)
body: <p>i use this code in a thread (through Indy Onexecute event) . is there any problem ?</p>
  
  <pre><code>function TFrmMain.ShellExecute_AndWait(FileName, Params: string): bool;
  var
    exInfo: TShellExecuteInfo;
    Ph: DWORD;
  begin
    FillChar(exInfo, SizeOf(exInfo), 0);
    with exInfo do
    begin
      cbSize := SizeOf(exInfo);
      fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
      Wnd := GetActiveWindow();
      exInfo.lpVerb := 'open';
      exInfo.lpParameters := PChar(Params);
      lpFile := PChar(FileName);
      nShow := SW_NORMAL;
    end;
    if ShellExecuteEx(@exInfo) then
      Ph := exInfo.hProcess
    else
    begin
      Result := true;
      exit;
    end;
    while WaitForSingleObject(exInfo.hProcess, 50) &lt;&gt; WAIT_OBJECT_0 do
    begin
  
    end;
    CloseHandle(Ph);
    Result := true;
  end;
  </code></pre>