List Of Processes

Started by
5 comments, last by MaggoT 19 years, 1 month ago
I got a question, how can i retrieve a list of the processes running on my computer with C++ & win32 api. I have an api reference tho, i don't know what to look for so it's hard to find it. So i would be greatful if one of you could tell me at least what api functions to use, and/or show me an example(not a must). MaggoT
Advertisement
Look at these:
How To Enumerate Applications Using Win32 APIs
Process Enumeration in Windows 2000

MSDN References:
ToolHelp Library
PSAPI


Regards,
jflanglois
Thanks i will take a look at those.
	#include <tlhelp32.h>	HANDLE         hProcessSnap = NULL;				BOOL           bRet      = FALSE;				PROCESSENTRY32 pe32      = {0};				int n = 0;				//  Take a snapshot of all processes in the system.				hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);				if (hProcessSnap == INVALID_HANDLE_VALUE)				   Application->MessageBox("Failed to walk the list of processes", "Failure retrieving Processes", MB_ICONERROR);				pe32.dwSize = sizeof(PROCESSENTRY32);				if (Process32First(hProcessSnap, &pe32))				{						do						{							pIDs[n] = pe32.th32ProcessID ;							ListBox2->Items->Add(pe32.szExeFile);							n++;						}						while (Process32Next(hProcessSnap, &pe32));				}            Label1->Caption = n;				CloseHandle (hProcessSnap);


This is from a Borland C++ Builder project of mine. pIDs is a long and pe32.szExeFile is a char * type.
Thanks Daerax, will take a closer look at that later.

Because going to get the list of processes when i get further into my program, but i got another problem with the win32 api.

I'm trying to create a groupbox (with CreateWindowEx()), this is what i've done:
CreateWindowEx(WS_EX_CLIENTEDGE, "STATIC"  , "Edit Memory", WS_VISIBLE|WS_CHILD|BS_GROUPBOX|SS_SIMPLE,10, 10, 500, 500, hwnd, (HMENU)IDI_GROUP1, GetModuleHandle(NULL), NULL);


And it does show up, but the text "Edit Memory" aint showing up on the group-box. I have checked the API Reference but found nothing that described the text without the "SS_SIMPLE" dwstyle.

What am i doing wrong?
Weird, but a groupbox is a "BUTTON" class, not a static.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Endurion: haha didn't think of that, i didn't remember last time i used it so no wonder why i thought it was a STATIC. Well thanks, it's working now.

This topic is closed to new replies.

Advertisement