Terminating a detached process started with CreateProcess
Posted on 2004-10-19
I am trying to terminate a process that I created using CreateProcess. I called:
if (CreateProcess(NULL, exeString, NULL, NULL, false, DETACHED_PROCESS, NULL, NULL, &startupInfo, &procInfo) == 0) ......
I then try to call TerminateProcess using the procInfo.hProcess handle. Everytime I do this I get an "invalid handle" error. Do I need to create the process with different flags? I am doing this on a Windows NT machine. The documentation says that the handle must have PROCESS_TERMINATE access. How do I give the handle this access?