#include <stdio.h> #include <Windows.h> #include <TlHelp32.h> int main(int argc, char *argv[]) { HANDLE SnapshotHandle; PROCESSENTRY32 ProcessEntry; BOOL Result; SnapshotHandle = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS,0); if (INVALID_HANDLE_VALUE == SnapshotHandle) { return 0; } ProcessEntry.dwSize = sizeof(PROCESSENTRY32); Result = Process32First(SnapshotHandle, &ProcessEntry); while (Result) { printf("ProcessID = %d, ProcessName = %s\r\n", ProcessEntry.th32ParentProcessID, ProcessEntry.szExeFile); Result = Process32Next(SnapshotHandle, &ProcessEntry); } return 0; }