windows api之EnumProcesses (查询系统所有进程ID)
发布网友
发布时间:2023-03-21 16:10
我来回答
共1个回答
热心网友
时间:2023-10-09 15:38
#include
#include
#include
#include
#pragma once
#pragma message("Psapi.h --> Linking with Psapi.lib")
#pragma comment(lib,"Psapi.lib")
int main(){
DWORD proId[500];
DWORD* pProId = proId;
DWORD totlaNum = 1000;
DWORD num = 4;
BOOL ret = EnumProcesses(pProId, totlaNum, &num);
for (int i = 0; i < 500; i++) {
printf("%d ", proId[i]);
}
}
}
#获取了系统所有进程ID之后,就可以遍历ID,对进程进行相关处理了。比如杀死进程,退出等