Differentiating between user processes and system?

BlitzMax Forums/BlitzMax Programming/Differentiating between user processes and system?

Gabriel(Posted 2005) [#1]
I'm using EnumWindows() to get a list of running processes, and then using GetWindowText and GetWindowModuleFileName to retrieve the window title and exe file path of the process. I thought EnumWindows was only supposed to list top level windows, but it's returning quite a bit of extra stuff too. So I'm still getting a shedload of useless processes. Things with either no name at all or it's a system process that I really shouldn't let the user stop anyway.

Is there a way of filtering out Windows/Processes? I'm only really looking for proper apps running, not just processes and windows system stuff.


Gabriel(Posted 2005) [#2]
Bump. Anyone? It must be possible, at least on 2k and XP, as Task Manager can differentiate between user processes and system processes.


Eikon(Posted 2005) [#3]
Maybe user32 IsWindowVisible(hWnd) might help weed a few of them out.

*edit*
You should be able to get the info from these functions
http://www.mentalis.org/apilist/CreateToolhelp32Snapshot.shtml


Gabriel(Posted 2005) [#4]
Thanks Eikon. I looked at the Snapshot stuff, but I'm not sure what tells me whether it's a system process or a user process. As far as I can see, it gives me a list of C Struct's with the following info :


dwSize
    Size of the structure, in bytes. Before calling the Process32First function, set this member to sizeof(PROCESSENTRY32). If you do not initialize dwSize, Process32First fails.
cntUsage
    This member is no longer used and is always set to zero.
th32ProcessID
    Process identifier.
th32DefaultHeapID
    This member is no longer used and is always set to zero.
th32ModuleID
    This member is no longer used and is always set to zero.
cntThreads
    Number of execution threads started by the process.
th32ParentProcessID
    Process identifier of the process that created this process (its parent process).
pcPriClassBase
    Base priority of any threads created by this process.
dwFlags
    This member is no longer used, and is always set to zero.
szExeFile
    Pointer to a null-terminated string that specifies the name of the executable file for the process. 


What am I looking for? The parent process id?


Eikon(Posted 2005) [#5]
I'm not sure, sorry. I was mainly referring to the EnumProcesses example from that page. I saw a lot of data in the structs there and was sure one of them had to hold the user/system data you needed. I enlisted the help of some API experts, keep an eye on this thread:

http://www.xtremevbtalk.com/showthread.php?p=1089069#post1089069