import pythoncom
import wmi
import threading
import time

class Info (threading.Thread):
def __init__ (self):
threading.Thread.__init__ (self)
def run (self):
print 'In Another Thread...'
pythoncom.CoInitialize ()
try:
c = wmi.WMI ()
for i in range (5):
for process in c.Win32_Process ():
print process.ProcessId, process.Name
time.sleep (2)
finally:
pythoncom.CoUninitialize ()

if __name__ == '__main__':
print 'In Main Thread'
c = wmi.WMI ()
for process in c.Win32_Process ():
print process.ProcessId, process.Name
Info ().start ()

posted on 2012-10-09 20:22  gjung  阅读(718)  评论(0编辑  收藏  举报