views:

148

answers:

1

Given two interface references obtained from different sources. Is there a programmatic way to tell whether they're implemented by the same instance?

A simple equality check of the interface references always fails.


EDIT: Large parts of the original question, which turned out to be an independent problem have now been moved to a new question.

+8  A: 

You could query for the IUnknown interface and compare these pointers. All other interface pointers are not guaranteed to return the same value each time.

from The Rules of the Component Object Model:

Object identity. It is required that any call to QueryInterface on any interface for a given object instance for the specific interface IUnknown must always return the same physical pointer value. This enables calling QueryInterface(IID_IUnknown, ...) on any two interfaces and comparing the results to determine whether they point to the same instance of an object (the same COM object identity).

HS