Enume all processes that are currently running

xiaoxiao2021-03-06  86

void CEmnuprocessDlg :: ListProcess () {HANDLE hProcessSnap = NULL; PROCESSENTRY32 pe32; // get the handle hProcessSnap = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0); if (hProcessSnap == (HANDLE) -1) {// printf ( "/ nCreateToolhelp32Snapshot () Failed:% D ", getLastError ()); AfxMessageBox (" CreateToolhelp32Snapshot () failed! ");}

pe32.dwSize = sizeof (PROCESSENTRY32); // name of the process according to the column if (Process32First (hProcessSnap, & pe32)) {do {m_ctrlListProcesses.AddString (pe32.szExeFile);} while (Process32Next (hProcessSnap, & pe32));} else {

AFXMessageBox ("Process32FINST () FAILED!"); // printf ("/ nprocess32finst () failed:% d", getLastError ());} CloseHandle (HProcessSnap);

Note: The header file used in STDAFX is joined to Tlhelp32.h

转载请注明原文地址:https://www.9cbs.com/read-124247.html

New Post(0)