注册的COM对象不能被python的win32com.client.dispatch() [英] Registered COM object not recognized by python's win32com.client.dispatch()

查看:7183
本文介绍了注册的COM对象不能被python的win32com.client.dispatch()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Python加载COM对象。我使用win32com.client.Dispatch(Name.Of.Object)来加载它,COM对象已注册regsvr32,并作为一个条目在我的注册表中的HKLM / CLSID和HKLM / Wow6432Node / CLSID 。我可以使用VBScript打开它只是罚款,但Python的win32com.client.Dispatch()给我这个错误:

I'm trying to load a COM object with Python. I'm using win32com.client.Dispatch("Name.Of.Object") to load it, and the COM object has been registered with regsvr32 and appears as an entry in my registry in both HKLM/CLSID and HKLM/Wow6432Node/CLSID. I can open it using VBScript just fine, but Python's win32com.client.Dispatch() gives me this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)

我读过有32 vs 64位的问题;我在一个64位的机器上运行这个32位的python和32位win32com。任何建议?

I have read that there are issues with 32 vs 64 bit; I'm running this on a 64-bit machine using 32-bit python and 32-bit win32com. Any suggestions?

请注意,VBScript中的此代码工作正常:

Note that this code in VBScript works fine:

Set obj = WScript.CreateObject( "Name.Of.Object" )


推荐答案

通过安装Python 64位和win32com 64位解决了这个问题。

Fixed this problem by installing Python 64 bit and win32com 64 bit.

这篇关于注册的COM对象不能被python的win32com.client.dispatch()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆