Here's a function I wrote for a tiny debugger I made a while back that gives some rudimentary info on processes (the whole script can be found here):
Code:
void process_snap(void) {
FILE *hFile;
HANDLE hSnapshot;
PROCESSENTRY32 ppe32E = { sizeof(PROCESSENTRY32) };
int proccount = 0;
if(NULL == (hFile = fopen("proc_snap.log","a"))) {
printf("+--Could not open log file--+\n");
goto end;
}
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(NULL == hSnapshot) {
fprintf(hFile,"+--Could not create process snapshot: %d--+\n",GetLastError());
goto end;
}
if(FALSE == Process32First(hSnapshot,&ppe32E)) {
fprintf(hFile,"+--Could not get first process: %d--+\n",GetLastError());
goto end;
}
fprintf(hFile,"+---PROCESS SNAP RESULTS:-----+\n");
do {
fprintf(hFile,"Process %d:\n",++proccount);
fprintf(hFile,"--Path: %s\n",ppe32E.szExeFile);
fprintf(hFile,"--ProcID: 0x%x\n",ppe32E.th32ProcessID);
} while(FALSE != Process32Next(hSnapshot,&ppe32E));
fprintf(hFile,"+-----------------------------+\n");
fprintf(hFile,"\n\n\n");
printf("+--Everything snapped, logs in proc_snap.log--+\n");
end:
fclose(hFile);
}
You can of course do it other ways, namely using things like the native API, but I feel that's beyond the basic scope of what you're asking (at least right now.)