Re: Looking for COM class that has methods with output parameters



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




.



Relevant Pages

  • Re: Problem with WM asf Filter when using with Dshow.
    ... >> Could you post the function where you are releasing the interface? ... >are initiatied at various points through the graph building. ... uninitialized before all interface pointers have been released. ...
    (microsoft.public.win32.programmer.directx.video)
  • Registering an interface in the Global Interface Table prevents destructor from being called
    ... I am writing an apartment threaded object that needs to share interfaces ... In an initialization routine I create the Global Interface ... If I revoke the interface from the GID before releasing the object, ... then the destructor is called correctly. ...
    (microsoft.public.vc.atl)
  • SLIPSTREAM3D VR INTERFACE COMPLETED!
    ... The Slipstream3D Interface is finished! ... I'm releasing it here first to get your impressions, comments, critiques, ... Criticism without any real solutions will be ignored. ...
    (comp.lang.vrml)
  • anyway common way to handle crash i com object?
    ... Any common way to handle com interface crash?actually i coudn't finout ... exact reason of crash..(crash coming in releasing time,once in a while) ...
    (microsoft.public.vc.mfc)
  • Re: IDispatch GetIDsFromNames
    ... Final interface was: ... pVarResult, ... pArgErr); ... Dominic Godin ...
    (microsoft.public.dotnet.languages.csharp)