Use the createconlhelp32snapshot/process32first/process32next API to enumerate system processes. In many cases, you need to operate system processes, there are many methods, but the most common method is createconlhelp32snapshot/process32first/process32next. A series of Apis enable the end process to use terminateprocess to enable the following functions to enumerate processes: int processlist () {processentry32 pe32; pe32.dwsize = sizeof (pe32); int COUNT = 0; handle hprocesssnap =: equals (th32cs_snapprocess, 0); If (hprocesssnap = equals) {printf ("creat Etoolhelp32snapshot call failed! "); Return-1;} bool bmore =: process32first (hprocesssnap, & pe32); printf (" % 20 s/t % 10 s/n "," process name ", "PID "); printf ("===========================================/ N "); while (bmore) {count ++; printf ("% 20 s/t % 10d/N", pe32.szexefile, pe32.th32processid); bmore =: process32next (hprocesssnap, & pe32 );}:: closehandle (hprocesssnap ); printf ("===========================================/ N "); printf ("/n current system process count: % d/N", count); Return 0 ;} To terminate a process, you can use the following function: (you can obtain the dwid as the ID of the process you want to terminate through the function of the process column) int terminateprocessfromid (DWORD dwid) {bool Bret = false; handle hprocess =: OpenProcess (process_all_access, false, dwid); If (hprocess! = NULL) {Bret =: terminateprocess (hprocess, 0); }:: closehandle (hprocess); If (BRET) printf ("% d process ended successfully ...... /n ", dwid); else printf (" % d process ended failed ...... /n ", dwid); Return 0;} process-related operations usually require elevation of permissions, you can refer to another note, "process permission escalation code. because the code is relatively simple, there is no more text description. The key functions are annotated. In fact, it is okay to call them directly.