0

I create a process with this command

CreateProcess(target, NULL, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi)

when I run this code with a special file , the process creates several threads, now I want to sure that all of that threads finished before I do something , I must use this function :

WaitForMultipleObjects( numThreads,    // number of threads to wait for 
                                     threadHandles, // handles for threads to wait for
                                     TRUE,          // wait for all of the threads
                                     INFINITE       // wait forever
                                    );

the second argument in this function is a array that contain handle of threads. now , how I get the handle of all threads that createprocess function create them

  • 2
    This is very fundamentally *not* the way it works. A process you start decides by itself when to shut itself down. Nothing you can do to stop that. Which has nothing to do with what kind of threads it creates, it is *very* common for a program to terminate itself when it still has active threads. Only using WaitForSingleObject(pi.hProcess, INFINITE) makes sense. – Hans Passant Sep 27 '14 at 14:09
  • http://stackoverflow.com/questions/9965784/how-to-obtain-list-of-thread-handles-from-a-win32-process – singh Sep 27 '14 at 14:34

0 Answers0