[python-win32] QueryInterface woes

Jens B. Jorgensen jens.jorgensen@tallan.com
Tue, 11 Feb 2003 18:12:40 -0600


Steven Scott wrote:

>On Tuesday 11 February 2003 5:59 pm, you wrote:
>  
>
>>wrapper module is called "Domino" and the object you have is called
>>an_item. All you need to do is:
>>
>>rti = Domino.IRichTextItem(an_item)
>>rti.SomeMethodYouCouldNotCallBefore()
>>
>>    
>>
>
>ok thanks that's a huge help
>
>is this seperate from the first time I ran makepy, for early binding?  
>basically, I don't know what to import.  the IRichTextItem wrapper class is 
>defined in the file made by makepy in the gen_py directory, but I don't know 
>how to import that.....I feel like I've done that before, but it's been over 
>a year.
>
when you run makepy.py (without the '-o' parameter) the wrapper module 
is created in the Lib/site-packages/win32com/gen_py dir as you surmise. 
A nice way to get this module explicitly in your script is by something 
like:

from win32com.client import gencache
Domino = gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', 
0, 5, 1)

replacing of course the above guid with the typelib, version ,lang, etc. 
with the ones for Domino.

>basically the only way I know how to access the COM stuff is by calling 
>Dispatch('Lotus.NotesSession') and calling methods on the returned object.
>
Yeah, and this works fine when you hitting the "default interface" which 
is implemented through IDispatch but once you have classes that support 
multiple interfaces you start needed to generate the wrappers and use 
the classes therein explicitly. It could be there's a generic way to get 
at the wrapper classes without explicitly getting the module as I have 
above. There is a way to get at constants like this but I always just go 
after the module explicitly. I think it makes my code clearer anyhow.

-- 
Jens B. Jorgensen
jens.jorgensen@tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"