[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-atl
Subject:    Re: Passing interfaces in a VARIANT?
From:       Jay Guidos <jay () GAIASOFTWARE ! COM>
Date:       1999-04-30 18:26:25
[Download RAW message or body]


Hi Scott,

You are correct.  If you hand out IUnknown or IDispatch pointers in VARIANTs
you must AddRef() them to keep them alive for [out] parameters, just as if
you were passing back the actual interface.

Jay Guidos
Gaia Software Inc

-----Original Message-----
From: Scott Stubbs <scott@CAPROCKCONSULTING.COM>
To: ATL@DISCUSS.MICROSOFT.COM <ATL@DISCUSS.MICROSOFT.COM>
Date: Friday, April 30, 1999 12:09 PM
Subject: Passing interfaces in a VARIANT?


Let's say I have a property define in IDL:

[id(00000000), propput]
    HRESULT Item(
                    [in] long nIndex,
                    [in] VARIANT* pItem);

[id(00000000), propget]
    HRESULT Item(
                    [in] long nIndex,
                    [out, retval] VARIANT* pRetItem);

If put_Item is called with an IUnknown in the VARIANT* pItem, I think I
should AddRef() it since I will be haning on to it internally.

If get_Item is called for that same IUnknown I should AddRef() it again and
pass it back to the caller in the VARIANT* pRetItem.  Is this correct?

I am also wandering if there are any other types within a VARIANT that I
need to take special consideration for as well?

Scott Stubbs
http://www.caprockconsulting.com
mailto:scott@caprockconsulting.com

----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic