OOPortal OOPortal


Basic COM  «Prev 

QueryInterface guidelines

For this discussion, assume we have a COM object with three interfaces IA, IB, and IC.

Symmetric property

The symmetric property states that if a call to IA::QueryInterface(IID_IB, ...) is successful, a call to IB::QueryInterface(IID_IA, ...) must be successful.

Reflexive property

The reflexive property states that a call to IA::QueryInterface(IID_IA, ...) must succeed.


Transitive property

The transitive property states that if a call to IA::QueryInterface(IID_IB, ...) succeeds, and is followed by a call to IB::QueryInterface(IID_IC, ...) that succeeds, than a call to IA::QueryInterface(IID_IC, ...) must succeed.
These rules enforce the basic navigation principle: Given a pointer into an instance of a COM object, a client must be able to navigate to an instance of another interface implemented by the object.
Note that the COM specification does not state which interface pointer is to return in these calls. An object can choose to return pointers to existing interfaces or create instances on demand. The only requirement constraining which interface pointer to return is for IUnknown. As stated previously, because IUnknown is used as an object's identity, all QueryInterface calls into any interface within the object must return the same value for IUnknown.