| Lesson 11
| QueryInterface guidelines
| Examine what the COM specification says about QueryInterface.
The COM specification provides significant detail about
Following is a summary of some of the essential points.
All interfaces within an instance of a COM object must always return the same value for
The reason for this is that the
IUnknown pointer is used to identify an instance of a COM object uniquely.
In the previous lesson, when asked for
IUnknown, we returned a pointer to the first interface in the object IMyComInterface.
The COM specification does not dictate what pointer values should be returned for other interfaces.
A client can call
QueryInterface and ask for
The object's implementation can choose to return the same
IMyComInterface pointer or create a new instance of
IMyComInterface for each request. In this example, because we are using multiple inheritance of classes with pure virtual functions,
we always return the same pointer value.
Symetric, reflexive, and transitive
symmetric, reflexive, and transitive
These requirements are intended to enforce the idea that once a client has an interface pointer into an object, it can navigate to any other interface within the object.
Query Interface - Quiz