title: Delphi - Gracefully Closing Created Process in Service. (using tprocess / createProcess)
body: <p>I have a Windows Service written in Delphi which runs a number of programs. </p>
  
  <p>On Stopping the service, I want to also close these programs. When the service was originally written, this worked fine, but I think I've updated the tProcess component and now - The subordinate programs are not being closed. </p>
  
  <p>in tProcess - Here's the code which starts the new processes. </p>
  
  <pre><code>  if CreateProcess( nil , PChar( FProcess.Command ) , nil , nil , False ,
      NORMAL_PRIORITY_CLASS , nil , Directory ,
      StartupInfo , ProcessInfo ) then
      begin
        if FProcess.Wait then
          begin
            WaitForSingleObject( ProcessInfo.hProcess , Infinite );
            GetExitCodeProcess( ProcessInfo.hProcess , ExitCode );
            if Assigned( FProcess.FOnFinished ) then
              FProcess.FOnFinished( FProcess , ExitCode );
          end;
        CloseHandle( ProcessInfo.hProcess );
        CloseHandle( ProcessInfo.hThread );
      end;
  </code></pre>
  
  <p>Each of the executables called by this are Windows GUI Programs (With a close button at the top). </p>
  
  <p>When I stop the service, I also want to stop (not kill) the programs I've started up via the createProcess procedure. </p>
  
  <p>How would you do this? </p>