Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: 4 Feb 2006 11:41:44 -0800,    group: microsoft.public.platformsdk.com_ole        back       


does _variant_t call AddRef()/Release() on contained IUnknowns/IDispatches?   
Does _variant_t call AddRef()/Release() on contained
IUnknowns/IDispatches?
Or do you have to do AddRef() manually when you stick something into a
variant and Release() on the old thing when you replace it with
something else?
date: 4 Feb 2006 11:41:44 -0800   author:   Jason S

Re: does _variant_t call AddRef()/Release() on contained IUnknowns/IDispatches?   
"Jason S"  wrote in message
news:1139082104.482280.18310@g47g2000cwa.googlegroups.com
> Does _variant_t call AddRef()/Release() on contained
> IUnknowns/IDispatches?

Yes.

> Or do you have to do AddRef() manually when you stick something into a
> variant and Release() on the old thing when you replace it with
> something else?

No, unless you assign it directly to the data member. E.g.

_variant_t var;
IDispatch* p;
var = p; // any previous content is released, the pointer is AddRef'ed

var.pDispVal = p;
// this bypasses _variant_t member functions and
// does not manage resources properly.
// Don't do this unless you are sure you know what you are doing and 
why.

-- 
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
date: Sat, 4 Feb 2006 15:46:14 -0500   author:   Igor Tandetnik

Re: does _variant_t call AddRef()/Release() on contained IUnknowns/IDispatches?   
aha! So _variant_t overloads '=' and sets its type accordingly.

I take it that AddRef()/Release() applies only if the _variant_t is a
VT_DISPATCH or VT_UNKNOWN, and not if the _variant_t is a VT_ARRAY of
VT_VARIANTs since those sub-VARIANTs are not _variant_t's themselves.

Is this stuff well-documented anywhere? The MSDN online docs for VC++
(both 6.0 and the most recent) are decent for the _variant_t
constructor but say nothing about the overloaded ='s effect on
addref/release.
>:( >:( >:(
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/html/_pluslang__variant_t.3a3a._variant_t.asp
http://msdn2.microsoft.com/wyc8836e.aspx
date: 4 Feb 2006 13:57:27 -0800   author:   Jason S

Re: does _variant_t call AddRef()/Release() on contained IUnknowns/IDispatches?   
> Is this stuff well-documented anywhere?

Just look at the source code.

Brian
date: Sat, 4 Feb 2006 14:35:39 -0800   author:   Brian Muth

Re: does _variant_t call AddRef()/Release() on contained IUnknowns/IDispatches?   
>Just look at the source code.

Huh. I didn't realize the source *was* available (it's all inline in
<comutil.h> ) Thanks.

Usually I prefer to RTFM than to UTSL, because of cryptic subtleties or
whatever... but in this case I have to admit that the source is pretty
clear.
date: 6 Feb 2006 07:11:48 -0800   author:   Jason S

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us