Click to See Complete Forum and Search --> : Passing event handles to a Child Process


tokeri51
November 20th, 2007, 02:33 PM
I Have a DLL running as part of Windows Service. This DLL creates a process, which processes files in a directory and then waits for more files to appear. I need to be able to tell the child process to terminate itself when the Windows Service stops. I tried to create an Event and pass the Handle to the child process and use WaitForMultipleObjects, but cannot get the right handle. Keeps ending the wait with error 6 (Invalid Handle)

Any help would be greatly appreciated.

tokeri51
November 20th, 2007, 03:07 PM
Found my problem!. Was creating the event without assigning inheritable handle. CreateEvent(NULL, TRUE, FALSE, NULL) is wrong. Should be:
CreateEvent(&saAttrib, TRUE, FALSE, NULL), with saAttrib.bInheritHandle set to TRUE.