[python-win32] QueryInterface fails with object passed from VB

Mark Hammond mhammond at skippinet.com.au
Sun Apr 27 12:53:21 CEST 2008


> Hi Mark,
> 
> Thanks for the answer, I tried using the IViewDataView's uiid like
> this (probably in a naive way):
> 
> y = view.QueryInterface("{8D2AD79B-1ADD-4181-BAD4-FF0672A9B6E3}")
> 
> But that produces the error on that line.
> 
> com_error: (-2147221005, 'Invalid class string', None, None)

Hrm - try passing 'pywintypes.IID("{8D2AD79B-1ADD-4181-BAD4-FF0672A9B6E3}")'
as the IID.

> I read that I can do the same thing with win32com (without using
> comtypes) but for that I would need to somehow add my custom interface
> to it. I also read that exist tools to automate this process but so
> far I could not find them. Where should I start?

Yeah - if the interface doesn't support IDispatch, your best bet is indeed
comtypes.  The code as it stands, once you sort out the simple issues, is
likely to end up with an E_NOINTERFACE exception :(

Mark



More information about the python-win32 mailing list