python在子线程中使用WMI报错-2147221020-moniker,i,bindCTX=pythoncom.MKParseDisplayName(Pathname)
来源:互联网 发布:bf风格的淘宝店 编辑:程序博客网 时间:2024/06/05 20:41
python在子线程中想要使用WMI查看一个进程是否活着,但是在子线程中调用时会出现如下错误:
后来查找原因发现需要在每次使用WMI时进行初始化:
#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
while True:
if check_exsit('gui_flash_programmer.exe') ==False:
lab[i].configure(text = "Flash programmer2 not open...")
lab[i].configure(bg = 'blue')
else:
lab[i].configure(bg = 'blue')
break
time.sleep(0.3)
lab[i].configure(bg = 'yellow')
time.sleep(0.3)
添加初始化方法后可以正常使用
阅读全文
0 0
- python在子线程中使用WMI报错-2147221020-moniker,i,bindCTX=pythoncom.MKParseDisplayName(Pathname)
- python在子线程中使用WMI报错-2147221020-moniker,i,bindCTX=pythoncom.MKParseDisplayName(Pathname)
- python在子线程中使用pyHook监控键盘无效,需要加pythoncom的初始化
- 为啥Toast在子线程报错
- 在C#中使用WMI
- 在MFC中使用WMI
- 子线程使用Toast报错
- Hbase在 Windows下运行报错 IllegalArgumentException: Pathname /D:/download/repository/org/apache/.....
- WMI编程之一:在VC中使用WMI
- Python 安装pythoncom、pyHook
- python中wmi介绍和使用
- 【脚本】python中wmi介绍和使用
- 在 PowerShell 中使用 WMI 远程调用
- python+selenium在Pycharm中使用alert报错问题解决
- 安卓在子线程中使用使用Toast
- 在 python 中使用 Selenium 报错self.capabilities = response['value'] KeyError: 'value'的解决办法
- 在子线程中new Handler报错--Can't create handler inside thread that has not called Looper.prepare()
- 在子线程中new Handler报错--Can't create handler inside thread that has not called Looper.prepare()
- 深入理解nodejs Event loop
- linux.查看定时任务,查看定时任务日志(类似于eclispe控制台)
- 探究HashMap数据结构
- 发附件含有压缩文件的邮件,出现压缩文件名乱码
- 关于在同一个网段互相ping不通的问题
- python在子线程中使用WMI报错-2147221020-moniker,i,bindCTX=pythoncom.MKParseDisplayName(Pathname)
- mysql 查询JSON类型数据
- work问题
- 杂记(个人对分布式与集群的理解)
- 为啥MyEclipse 10jsp文件打代码没有加载提示,个人解决方案
- Django REST framework 截图教程
- Lintcode三角形计数
- 51Nod
- 秒懂词向量Word2vec的本质