Terminate a process tree (C for Windows) -


Previously asked, but I have not received a definitive answer, in code.

Open a process, Process A (with PID 1234) This process opens a hair process, Processab (PID 5678). After finishing I finish Process A, but I still have an anchor of processab.

How can I eliminate the entire process tree? What do I mean, how can I ensure that if I end the process that is opened then I am ending all the related processes?

Thanks

The code is appreciated.

Check grouping processes within "Work"

If it does not work for you,

  • call to calculate all the processes on the system
  • Check the member of th32ParentProcessID
  • PROCESSENTRY32 structure on each process, if it matches your parent ID, then process ends (usage)
  • after the expiry of all children, terminate the main process
  • Sample code:

      DWORD myprocid = 1234; // your main process ID PROCESSENTRY32; Memset (and PE, 0, size (PROCESSENTRY32)); PE.wcz = size (PROCESSENTRY32); Handle HSNP = :: CreateToolhelp32 snapshot (TH32CS_SNAPPROCESS, 0); If (:: Process32First (HSNAP, and PE)) {BOOL bContinue = TRUE; // Beating During Hair Procedures (Bekinineue) {// Only kill child procedures if (PATP 32 propasidad == myprocid) {handle H childproc = = open procedure (Process_LACACAS, Fellsea, P. throproacid); If (hChildProc) {: Terminator process (HK childproc, 1); :: CloseHandle (hChildProc); }} BContinue = :: Process 32 Next (HSNAP, and PE); } // Kill the main process. PRCC = :: Open Process (Process_Oola_ACSS, Failse, MyProod); If (hProc) {: Terminate Process (HPRC, 1); :: CloseHandle (hProc); }}  

    Comments

    Popular posts from this blog

    c# - ListView onScroll event -

    PHP - get image from byte array -

    Linux Terminal Problem with Non-Canonical Terminal I/O app -