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: Fri, 06 Jan 2006 23:44:14 +0000,    group: microsoft.public.platformsdk.com_ole        back       


Quick question about VARIANTs   
Hello,

I am using a VARIANT to pass an IDispatch pointer into a collection 
class I got from the net. When the dispatch is put into the variant it 
seems to be calling AddRef() on the dispatch pointer. Is this normal?

I know this is the problem because a quick cal to Release() on the 
pointer just after the VARIANT is created solves the problem.
date: Fri, 06 Jan 2006 23:44:14 +0000   author:   Phil Da Lick!

Re: Quick question about VARIANTs   
Phil Da Lick!  wrote:
> I am using a VARIANT to pass an IDispatch pointer into a collection
> class I got from the net. When the dispatch is put into the variant it
> seems to be calling AddRef() on the dispatch pointer. Is this normal?

VARIANT is a plain C structure. It's not calling anything on anything - 
it does not have any code. _You_ must AddRef a pointer that you place 
into VARIANT.

> I know this is the problem because a quick cal to Release() on the
> pointer just after the VARIANT is created solves the problem.

What problem?
-- 
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: Fri, 6 Jan 2006 18:51:24 -0500   author:   Igor Tandetnik

Re: Quick question about VARIANTs   
Igor Tandetnik wrote:
> Phil Da Lick!  wrote:
> 
>>I am using a VARIANT to pass an IDispatch pointer into a collection
>>class I got from the net. When the dispatch is put into the variant it
>>seems to be calling AddRef() on the dispatch pointer. Is this normal?
> 
> 
> VARIANT is a plain C structure. It's not calling anything on anything - 
> it does not have any code. _You_ must AddRef a pointer that you place 
> into VARIANT.

Weird. Guess I'll have to have a closer look.


>>I know this is the problem because a quick cal to Release() on the
>>pointer just after the VARIANT is created solves the problem.
> 
> 
> What problem?

The problem of one of my objects (the one being stored as a dispatch in 
a variant in a collection) not being freed.
date: Sat, 07 Jan 2006 00:08:25 +0000   author:   Phil Da Lick!

Re: Quick question about VARIANTs   
"Phil Da Lick!" 
wrote in message
news:43bf066d$0$82643$ed2619ec@ptn-nntp-reader03.plus.net
> Igor Tandetnik wrote:
>> What problem?
>
> The problem of one of my objects (the one being stored as a dispatch
> in a variant in a collection) not being freed.

Somewhere you are not maintaining reference count correctly. Throwing 
AddRef's and Releases into the code at random in hopes the problem goes 
away might not be the best strategy.
-- 
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: Fri, 6 Jan 2006 20:56:29 -0500   author:   Igor Tandetnik

Google
 
Web ureader.com


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