Registered COM object not recognized by python's win32com.client.dispatch()

无人久伴 提交于 2019-12-23 13:07:03

问题


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)

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?

Note that this code in VBScript works fine:

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

Thanks


回答1:


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



来源:https://stackoverflow.com/questions/11297381/registered-com-object-not-recognized-by-pythons-win32com-client-dispatch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!