[python-win32] Casting to interface from different typelib?
Ben Gordon
dbg1000 at gmail.com
Sun Jan 11 07:34:44 CET 2009
Mark,
MH> pB = mod.InterfaceB(pA.QueryInterface(IID_B, pythoncom.IID_IDispatch))
Thanks so much for the suggestion. I tried it, but it appears that pA
does not provide a QueryInterface method.
<output>
File "c:\Python25\lib\site-packages\win32com\client\__init__.py",
line 454, in __getattr__
raise AttributeError, "'%s' object has no attribute '%s'" %
(repr(self), attr)
AttributeError: '<win32com.gen_py.TypelibA.InterfaceA instance at
0x13106712>' object has no attribute 'QueryInterface'
</output>
Does this mean I'm out of luck?
MH> It might also be worth seeing if we can fix that somehow - eg, maybe
an optional param allowing the interface and the object itself to be in
those different typelibs.
I'm not sure what magic is involved behind the scenes, but this type of
cast seems to be comparatively convenient and nearly transparent in
VBA/VB (VB requires an explicit CType call), without the need to lookup
CLSIDs/IIDs.
Thanks again,
-Ben
More information about the python-win32
mailing list