|
Luigi Auriemmaaluigi.org (ARCHIVE-ONLY FORUM!) |
|
It is currently 19 Jul 2012 14:46
|
View unanswered posts | View active topics
|
Page 1 of 1
|
[ 1 post ] |
|
Author |
Message |
aluigi
|
Post subject: processes list on Windows Posted: 27 Aug 2007 21:09 |
|
Joined: 13 Aug 2007 21:44 Posts: 4068 Location: http://aluigi.org
|
The function for listing the modules on Windows is so short that I have pasted it directly in this message.
This function (derived by some code I found posted on extalia.com) can be useful to many people and as already said shows the modules.
Each process has its modules and the first module of a process is just the main executable while the others are (usually) the dll files called by it.
If you don't need all these informations you can directly remove the second STARTPROC so you will have only the process.
Watch the Win32 API guide for the info contained in PROCESSENTRY32 and MODULEENTRY32:
#include <windows.h>
#include <tlhelp32.h>
void process_list(void) {
PROCESSENTRY32 Process;
MODULEENTRY32 Module;
HANDLE snapProcess,
snapModule;
BOOL b;
#define STARTPROC(X,Y) \
snap##X = CreateToolhelp32Snapshot(Y, Process.th32ProcessID); \
X.dwSize = sizeof(X); \
for(b = X##32First(snap##X, &X); b; b = X##32Next(snap##X, &X)) { \
X.dwSize = sizeof(X);
#define ENDPROC(X) \
} \
CloseHandle(snap##X);
Process.th32ProcessID = 0;
STARTPROC(Process, TH32CS_SNAPPROCESS)
STARTPROC(Module, TH32CS_SNAPMODULE)
printf("%s\n", Module.szExePath);
ENDPROC(Module)
ENDPROC(Process)
#undef STARTPROC
#undef ENDPROC
}
|
|
Top |
|
|
|
|
|
|
|
|
Page 1 of 1
|
[ 1 post ] |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|