Re: Looking for COM class that has methods with output parameters
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Wed, 20 Sep 2006 09:51:28 -0700
What contradiction do you see? pVarResult is a pure [out]
argument of IDispatch::Invoke (a COM interface). That means
the implementor is prohibited from releasing anything the
VARAINT might contain - it's presumed to be uninitialized.
Therefore, the client is responsible for prior cleanup - exactly
what the text says!
At any rate, I was talking about methods of dual interfaces,
not IDispatch...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"David Liebtag" <liebtag@xxxxxxxxxx> wrote in message
news:Oi9ipYL3GHA.3828@xxxxxxxxxxxxxxxxxxxxxxx
Alexander,
Your statement seems to me to contradict the MSDN documentation. You
wrote:
An [out] parameter by definition contains garbage on input.
It _must_not_ be freed to avoid crashes.
The Passing Parameters section of the MSDN discussion of the
IDispatch::Invoke documentation states:
The calling code is responsible for releasing all strings and objects
referred to by rgvarg[ ] or placed in *pVarResult. As with other
parameters that are passed by value, if the invoked member must maintain
access to a string after returning, you should copy the string. Similarly,
if the member needs access to a passed-object pointer after returning, it
must call the AddRef function on the object. A common example occurs when
an object property is changed to refer to a new object, using the
DISPATCH_PROPERTYPUTREF flag.
I interpretted this to mean that whether my calling code filled rgvarg
with an input variant or the called member filled it with an output
parameter, after the call, my code should free the variants in rgvarg.
Can you please explain the discrepancy?
Thank you.
David Liebtag
.
- Follow-Ups:
- Re: Looking for COM class that has methods with output parameters
- From: David Liebtag
- Re: Looking for COM class that has methods with output parameters
- References:
- Looking for COM class that has methods with output parameters
- From: David Liebtag
- Re: Looking for COM class that has methods with output parameters
- From: David Liebtag
- Re: Looking for COM class that has methods with output parameters
- From: Alexander Nickolov
- Re: Looking for COM class that has methods with output parameters
- From: David Liebtag
- Re: Looking for COM class that has methods with output parameters
- From: Alexander Nickolov
- Re: Looking for COM class that has methods with output parameters
- From: David Liebtag
- Looking for COM class that has methods with output parameters
- Prev by Date: Re: Conformant IDL array trouble
- Next by Date: Re: Conformant IDL array trouble
- Previous by thread: Re: Looking for COM class that has methods with output parameters
- Next by thread: Re: Looking for COM class that has methods with output parameters
- Index(es):
Relevant Pages
|