1 HANDLE hProcessSnap; 2 PROCESSENTRY32 pe32; 3 BOOL bProcess; 4 int p =0; 5 i = 0; 6 for (p=0;p<130;p++) { 7 Count[p]=(char*)malloc(sizeof(char)*130*32); 8 } 9 hProcessSnap=CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0);//创建进程快照 10 if( hProcessSnap == INVALID_HANDLE_VALUE ) 11 { 12 OutputDebugString(L"[fProcessMonitor]: INVALID_HANDLE_VALUE"); 13 return FALSE;//创建快照失败 不能列举进程 返回 14 } 15 16 pe32.dwSize = sizeof( pe32 ); 17 bProcess = Process32First( hProcessSnap, &pe32 ); 18 do//遍历进程列表查找 19 { 20 strcpy(Count[i],pe32.szExeFile); 21 OutputDebugString(Count[i]); 22 i++; 23 // MessageBoxA(NULL,"111","0000000",MB_OK); 24 }while( Process32Next( hProcessSnap, &pe32 ) );