471,605 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

How do I compare 2 objects which reference COM objects?

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

Jan 5 '06 #1
2 1981
You should be able to QueryInterface for IUnknown and compare the pointers.

--
Colin Neller
http://www.colinneller.com/blog
"Uzi" <ha*****@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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

Jan 5 '06 #2

"Uzi" <ha*****@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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.
Jan 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Helmut Jarausch | last post: by
8 posts views Thread by laniik | last post: by
19 posts views Thread by David zhu | last post: by
14 posts views Thread by Samuel R. Neff | last post: by
2 posts views Thread by Locia | last post: by
7 posts views Thread by Prabhudhas Peter | last post: by
50 posts views Thread by titan nyquist | last post: by
6 posts views Thread by Tony | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.