hoboo的专栏:在windows里通过进程控制块获取所有当前所有进程-
作者:[db:作者]
时间:2021-06-14 12:45
#include "stdafx.h"
#include <windows.h>
#include <tlhelp32.h>
int main(int argc, char* argv[])
{
?HANDLE hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
?if (!hSnapshot)
?{
??printf("CreateToolhelp32Snapshot ERROR!/n");
??return 1;
?}
?PROCESSENTRY32 pe32;
?pe32.dwSize = sizeof(PROCESSENTRY32 );
?if (!Process32First (hSnapshot, &pe32))
?{
??printf("Process32First ERROR!/n");
?}
?do
?{
??printf("ProcID:%d---%s/n",pe32.th32ProcessID ,pe32.szExeFile );
?}while(Process32Next (hSnapshot, &pe32));
?return 0;
}