欢迎使用6miu-markdown编辑器

xiaoxiao2021-02-28  127

显示系统所有进程的信息

#include <stdio.h> #include <Windows.h> #include <TlHelp32.h> #define TH32CS_SNAPNOHEAPS 0x40000000 int main(int argc, _TCHAR* argv[]) { PROCESSENTRY32 pe32; pe32.dwSize = sizeof(pe32); HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS|TH32CS_SNAPNOHEAPS,0); if(hProcessSnap == INVALID_HANDLE_VALUE) { printf("CreateToolhelp32Snapshot error!\n"); getchar(); return 0; } BOOL bMore = ::Process32First(hProcessSnap, &pe32); while(bMore){ printf("进程名称:%s\n",pe32.szExeFile); printf("进程ID:%u\n",pe32.th32ProcessID); bMore = ::Process32Next(hProcessSnap,&pe32); } ::CloseHandle(hProcessSnap); getchar(); return 0; }
转载请注明原文地址: https://www.6miu.com/read-34350.html

最新回复(0)