Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

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.
0
mbishop
Asked:
mbishop
  • 2
1 Solution
 
Tommy HuiCommented:
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

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now