CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Processes: How can I wait until a process ends?

  1. #1
    Join Date
    May 2000
    KY, USA

    Processes: How can I wait until a process ends?

    Q: How can I wait until a process ends?

    A: Depending on the method chosen for creating the process, waiting until it is finished is pretty easy to implement. 'CreateProcess()' provides handles both to the process and its primary thread within the 'PROCESS_INFORMATION' structure. The process handle can be used to wait for termination of the process:

    // Wait until application has terminated
    WaitForSingleObject(piProcessInfo.hProcess, INFINITE);
    // Close process and thread handles
    'ShellExecuteEx()' provides only a handle to the process but unfortunately it is not guaranteed and is depending on several options you can set within the 'SHELLEXECUTEINFO' structure. For any other method used to create the process a handle to the process needs to be obtained first.

    Last edited by Andreas Masur; July 21st, 2005 at 04:56 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)