python在子线程中使用WMI报错-2147221020-moniker,i,bindCTX=pythoncom.MKParseDisplayName(Pathname) ——转载

判断电脑是否存在某进程

#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 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/lshdp/article/details/83863022
今日推荐