server, but in different apartments. Then again, this may actually
be desired behavior...
Jason S <jmsachs@gmail.com> wrote:
On Apr 17, 5:24 pm, "Igor Tandetnik" <itandet...@mvps.org> wrote:
HRESULT Equals([in] IMyInterface* other, [out, retval] VARIANT_BOOL
ret);
sure, this is an obvious choice for interface. But the implementation
seems far from obvious, since the two objects can't talk to each other
in C++
I suggest implementing a private interface alongside IMyInterface. Mark it
[local] in the IDL. A method on this interface can even return a raw C++
pointer to the object, e.g. as a void* pointer.
A variation of this technique goes like this:
class CMyComObject {
BEGIN_COM_MAP(CMyComObject)
// ...
COM_INTERFACE_ENTRY_IID(GUID_INTERNAL, CMyComObject)
END_COM_MAP()
};
GUID_INTERNAL is a new GUID you define in your C++ files and never mention
in any IDL. QueryInterface for this GUID only works within the same
apartment, and produces a raw C++ pointer to the underlying object. If the
QI call fails, then either this instance comes from a different server, or
it's somebody else's implementation of IMyInterface. In either case, you
can simply declare the two objects to not be equal.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925