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