python在子執行緒中使用WMI報錯-2147221020-moniker,i,bindCTX=pythoncom.MKParseDisplayName(Pathname) ——轉載
阿新 • • 發佈:2018-12-07
判斷電腦是否存在某程序:
#check_exsit
def check_exsit(process_name):
#線上程中使用需要加初始化和去初始化方法
pythoncom.CoInitialize()
WMI = win32com.client.GetObject('winmgmts:')
processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % process_name)
if len(processCodeCov) >0:#判斷操作
print '%s is exists' % process_name
pythoncom.CoUninitialize()
return True
else:
print '%s is not exists' % process_name
pythoncom.CoUninitialize()
return False
---------------------
作者:gmq_syy
來源:CSDN
原文:https://blog.csdn.net/gmq_syy/article/details/76588589
版權宣告:本文為博主原創文章,轉載請附上博文連結!