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 10 hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); //创建进程快照 11 12 if( hProcessSnap == INVALID_HANDLE_VALUE ) 13 { 14 OutputDebugString(L"[fProcessMonitor]: INVALID_HANDLE_VALUE"); 15 return FALSE; //创建快照失败 不能列举进程 返回 16 } 17 18 pe32.dwSize = sizeof( pe32 ); 19 bProcess = Process32First( hProcessSnap, &pe32 ); 20 do //遍历进程列表查找 21 { 22 23 strcpy(Count[i],pe32.szExeFile); 24 OutputDebugString(Count[i]); 25 i++; 26 // MessageBoxA(NULL,"111","0000000",MB_OK); 27 }while( Process32Next( hProcessSnap, &pe32 ) );
时间: 2024-09-30 06:26:06