How do I compare 2 objects which reference COM objects?

  • Thread starter Thread starter Uzi
  • Start date Start date
U

Uzi

Hi,
I have 2 references to COM objects (through interop). How do I compare
the tow to know if they are pointing to the same COM object?
The Object.Equals doesn't work in this case...
Thanks!
Uzi
 
Uzi said:
Hi,
I have 2 references to COM objects (through interop). How do I compare
the tow to know if they are pointing to the same COM object?
The Object.Equals doesn't work in this case...
Thanks!
Uzi

IntPtr IUnkn1 = Marshal.GetIUnknownForObject(o1);
IntPtr IUnkn2 = Marshal.GetIUnknownForObject(o2);
if (IUnkn1 == IUnkn2)
// same object
else
....


Willy.
 
Back
Top