PyIUnknown = QueryInterface(iid, useIID )

Queries an object for a specific interface.


iid : IID

The IID requested.

useIID=None : IID

If provided and not None, will return an interface for the specified IID if (and only if) a native interface can not be supported. If the interface specified by iid is natively supported, this option is ignored.


The useIID parameter is a very dangerous option, and should only be used when you are sure you need it! By specifying this parameter, you are telling the COM framework that regardless of the true type of the result (as specified by iid), a Python wrapper of type useIID will be created. If iid does not derive from useIID, then it is almost certain that using the object will cause an Access Violation.
For example, this option can be used to obtain a PyIUnknown object if pythoncom does not natively support the interface. Another example might be to return an unsupported persistence interface as a PyIPersist instance.
For backwards compatibility: the integer 0 implies None, and the integer 1 implies IID_IUnknown.

Return Value

The result is always an object derived from PyIUnknown. Any error (including E_NOINTERFACE) will generate a com_error exception.