CComVariant

This is a discussion on CComVariant within the Windows Programming forums, part of the Platform Specific Boards category; Hello everyone, In the book ATL Internals, here is the description for CComVariant. My questions, -------------------- COM permits an object ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    CComVariant

    Hello everyone,


    In the book ATL Internals, here is the description for CComVariant. My questions,

    --------------------
    COM permits an object to hand out different binary values each time a client queries it for a specific interface pointer (with the exception of a query for the IUnknown interface). Therefore, two VARIANTs containing IDispatch pointers referencing the same object might not compare for equality.
    --------------------

    1.

    I think it means even if the pointer binary values are different, they may still be pointed to the same object? Right?

    I think it happens only in the situation of multiple inheritance, and in single inheritance, there is no such issue. Right?

    2.

    I think the above statement describes the following scenario, in multiple inheritance, suppose we have interface A inherits from IDispose, and interface B inherits from IDispose, and have inteface C inherits from both A and B.

    The queryInterface for A and B from interface C will return different result.


    thanks in advance,
    George

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,296
    Quote Originally Posted by George2 View Post
    Hello everyone,


    In the book ATL Internals, here is the description for CComVariant. My questions,

    --------------------
    COM permits an object to hand out different binary values each time a client queries it for a specific interface pointer (with the exception of a query for the IUnknown interface). Therefore, two VARIANTs containing IDispatch pointers referencing the same object might not compare for equality.
    --------------------

    1.

    I think it means even if the pointer binary values are different, they may still be pointed to the same object? Right?

    I think it happens only in the situation of multiple inheritance, and in single inheritance, there is no such issue. Right?

    2.

    I think the above statement describes the following scenario, in multiple inheritance, suppose we have interface A inherits from IDispose, and interface B inherits from IDispose, and have inteface C inherits from both A and B.

    The queryInterface for A and B from interface C will return different result.
    Yep, you got it. One pointer might be to the A interface and the other might be to the B interface, and A != B. But the IUnknown interface can be obtained form either A of B and these will both be equal.
    CComPtr::IsEqualObject comes in handy here!
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks iMalc,


    You mean C multi-inherits from A and B in your below description?

    Quote Originally Posted by iMalc View Post
    Yep, you got it. One pointer might be to the A interface and the other might be to the B interface, and A != B. But the IUnknown interface can be obtained form either A of B and these will both be equal.
    CComPtr::IsEqualObject comes in handy here!

    regards,
    George

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,296
    Quote Originally Posted by George2 View Post
    You mean C multi-inherits from A and B in your below description?
    Yes. It's very common in COM to inherrit (hence implement) multiple interfaces. I've worked with code that implemented over a dozen interfaces.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks iMalc,


    Question answered.

    Quote Originally Posted by iMalc View Post
    Yes. It's very common in COM to inherrit (hence implement) multiple interfaces. I've worked with code that implemented over a dozen interfaces.

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why is this not working??? PLEASE HELP ANYONE!!!!
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 06-26-2002, 01:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21