Two COM Questions: QueryInterface, and Callback Inheritance
Alex Martelli
alex at magenta.com
Wed Jul 26 04:30:10 EDT 2000
"Christopher Paulicka" <cpaulicka at 8cs.com> wrote in message
news:Bosf5.51489$DH3.1693859 at news-east.usenetserver.com...
[snip]
> > How to QueryInterface for a new dispatch interface?
[snip]
> Well, that seems straightforward. But, I get the following error message:
> >>> other_s = s._oleobj_.QueryInterface("{new_iid}")
> TypeError: There is no interface object registered that supports this IID
So the IID you're trying to QI for appears not to be registered as an IID.
_IS_ it, in fact, an *INTERFACE* id? It seems not, from the following
snippet:
> # If I get the type of s, and try to use it's CLSID, that doesn't work.
...right: a CLSID is a class-id, it identifies a coclass, not an interface.
You cannot QI for a CLSID, but only for an IID.
Both CLSID's and IID's are GUID's, but they are registered and used
differently. You can't QI for a class-id, just as you can't
CoCreateInstance
*without* specifiying a class-id.
> if ret is not None: ret = win32com.client.Dispatch(ret, 'Duration',
> '{EB5093C7-56F9-11D2-88CE-00C04FA35859}', UnicodeToString=1)
> return ret
>
> # Now it works fine!
Yep, but the third argument to Dispatch is a class-id, not an IID.
So maybe I've not understood what is it that you're trying to do. If
you want to access another interface of an object you already have
a reference to, then QI is correct, but you have to specify the interface
identification -- the IID, not the CLSID. If you want to instantiate a
brand-new object, then the CLSID is correct. But that is a
substantially different task.
Alex
More information about the Python-list
mailing list