[python-win32] win32com.client.gencache.EnsureModule works but win32com.client.Dispatch does not for a certain TypeLib

Roger Upole rupole at hotmail.com
Wed Mar 27 17:15:17 CET 2013


You'll need to use 32-bit python to be able to load a 32-bit COM object directly.

     Roger

"Costis Hatzopoulos" <costishatzopoulos at gmail.com> wrote in message 
news:CAMFgko=J+TwSr1QfQqZE4YhRVt5-=r-qtn=-ijf_DDhPcXz8mg at mail.gmail.com...
> Hello,
>
> I have updated to the latest version of python-win32 on Windows 7 64bit,
> default CPython 2.7.3 64bit installation. Everything seems to work fine for
> all other application (Excel and ZwCAD) except a commercial one that I have
> installed on my system. I do the following:
>
> Run makepy.py with the -i argument and I pick EP_XmlProject  1.0 Type
> Library which shows the following:
>
> {470874B8-3526-4DDB-BB88-7A8D7E968E3E}, lcid=0, major=1, minor=0
> >>> # Use these commands in Python code to auto generate .py support
> >>> from win32com.client import gencache
> >>> gencache.EnsureModule('{470874B8-3526-4DDB-BB88-7A8D7E968E3E}', 0, 1,
> 0)
>
> In PythonWin:
>>>> import win32com.client as wc
>>>> mod =
> wc.gencache.EnsureModule('{470874B8-3526-4DDB-BB88-7A8D7E968E3E}', 0, 1, 0)
>>>> print mod
> <module 'win32com.gen_py.470874B8-3526-4DDB-BB88-7A8D7E968E3Ex0x1x0' from
> 'C:\Python27\lib\site-packages\win32com\gen_py\470874B8-3526-4DDB-BB88-7A8D7E968E3Ex0x1x0.py'>
>
> this means that the module is created. I can verify that the module exists
> in 'C:\Python27\Lib\site-packages\win32com\gen_py\'
>
> the in the PythonWin I do the following:
>>>> print wc.gencache.GetClassForProgID('EP_XmlProject.EPX_App')
> win32com.gen_py.470874B8-3526-4DDB-BB88-7A8D7E968E3Ex0x1x0.EPX_App
>
> then if I try to do:
>>>> app = wc.Dispatch('EP_XmlProject.EPX_App')
> Traceback (most recent call last):
>  File "<interactive input>", 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
> 114, in _GetGoodDispatchAndUserName
>    return (_GetGoodDispatch(IDispatch, clsctx), userName)
>  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 91,
> in _GetGoodDispatch
>    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147221164, 'Class not registered', None, None)
>
> I'm completely stuck!!! To make things worst In my home XP Box, CPython
> 2.7.3 32bit and pywin32-217 everything works fine!
>
> Regards,
>
> Costis Hatzopoulos
>


--------------------------------------------------------------------------------


> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
> 





More information about the python-win32 mailing list