Spawning Win32 apps and waiting for completion

Begining programmer's question:  How do I spawn a Win32 app and wait for it to complete before returning to the parent application, or get the parent to detect completion before continuing?  Any help would be greatly appreciated.
mbishopAsked:
Who is Participating?
 
Tommy HuiConnect With a Mentor EngineerCommented:
You will need to use CreateProcess() and with the HANDLE returned, you need to use WaitForSingleObject() to wait until the handle is closed. This happens when the application exits.
0
 
nietodCommented:
Actually, to be more precise you want to wait for the handle to be SIGNALED not CLOSED.  The handle will still be open by your application and possibly by others.  When you are done waiting (when WaitForSingleObject() returns) remember to close your copy of the handle and also the primary thread handle (this is discussed in the CreateProcess() documentation).
0
 
mbishopAuthor Commented:
Would it be possible to get an example?  Meanwhile I'll start reading about the above-mentioned items.
0
 
mbishopAuthor Commented:
Could I get an example?
0
All Courses

From novice to tech pro — start learning today.