• Advertisement
Sign in to follow this  

List Of Processes

This topic is 4737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
	

#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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement