getting windows processes list
Grant Griffin
Grant_member at newsguy.com
Tue Jun 4 12:14:02 EDT 2002
In article <mailman.1023145566.5739.python-list at python.org>, "Mike says...
>
>If I'm not mistaken, win32pdh should be able to get the information
>using a process counter. WSH might also be able to get at it.
>
>HTH,
>Mike
>
>PS: Grant, your email address bounces.
Thanks, Mike (and all!)--win32pdh led me to the answer.
My purpose was to determine when a NetMeeting session had ended. The problem
with NetMeeting is that program control returns after just a few seconds even if
NetMeeting is still running. So, recognizing that Microsoft typically provides
more than one way to skin its cats, I decided to use NetMeeting's process name
to determine if it was running.
Based on Mike's tip, I hunted through win32pdh, which led me to win32pdhutil. I
adapted the routine below from win32pdhutil's "GetPerformanceAttributes" to get
a list of the names of all processes; if "conf" (the secret code for
"NetMeeting") appears in the list, NetMeeting is presumed to still be running.
god-bless-microsoft-for-making-everything-so-complicated-<wink>-ly y'rs,
=g2
-----------
def GetProcessNames(object="Process", counter="ID Process",
format=win32pdh.PDH_FMT_LONG, machine=None,
bRefresh=1):
if bRefresh: # PDH docs say this is how you do a refresh.
win32pdh.EnumObjects(None, machine, 0, 1)
items, names = win32pdh.EnumObjectItems(None, None, object, -1)
return names
_________________________________________________________________________
Grant R. Griffin g2 at dspguru.com
Publisher of dspGuru http://www.dspguru.com
Iowegian International Corporation http://www.iowegian.com
More information about the Python-list
mailing list