#define WIN32_LEAN_AND_MEAN #include #include int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HANDLE hSnap; if((hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) == INVALID_HANDLE_VALUE){ MessageBox(NULL, "CreateToolhelp32Snapshot", "Error", MB_OK); return -1; } PROCESSENTRY32 pe; pe.dwSize = sizeof(pe); UINT len = 0; TCHAR buf[4048]; BOOL bResult = Process32First(hSnap, &pe); while(bResult){ len += wsprintf(buf + len, TEXT("%s (0x%08x)\n"), pe.szExeFile, pe.th32ProcessID); bResult = Process32Next(hSnap, &pe); } CloseHandle(hSnap); MessageBox(NULL, buf , "OK", MB_OK); return 0; }