Windows上で実行中のプロセスを表示

Deviare(http://www.nektra.com/products/deviare-api-hook-windows/)
Python Win32 Extensions(http://python.net/crew/mhammond/win32/Downloads.html)
実行するにはこの二つがインストされてること。
Deviareの練習がてらに書いてみました。

import win32com.client

def ProcessList():
    spy = win32com.client.Dispatch("Deviare.SpyMgr")
    proc = spy.Processes
    enum = spy.Processes.Enumerator
    last = enum.Last
    i = enum.First

    print "%d process running" % proc.Count
    while i.Name != last.Name:
        print i.Name
        i = enum.Next
        pass
    print last.Name
    pass

if __name__ == "__main__":
    ProcessList()
    pass

実行結果

72 process running
[System Process]
System
dwm.exe
AppleMobileDeviceService.exe
mDNSResponder.exe
svchost.exe
smss.exe
ekrn.exe
csrss.exe
wininit.exe
csrss.exe
explorer.exe
services.exe
winlogon.exe
lsass.exe
lsm.exe
pythonw.exe
(以下省略)