Invoke with IDispatch* params

Ove Kaaven ovek at arcticnet.no
Wed Jul 23 06:11:39 CDT 2003


ons, 23.07.2003 kl. 12.02 skrev Mike Hearn:
> Hi, more questions (i'll master COM yet :)
> 
> HRESULT IWebBrowser2::get_Document(IDispatch **ppDisp);

Hmm. I assume this is an argument marked [out].

> invocation of this method/property fails, for some reason. I'm not sure
> why yet, but I don't understand how this is marshalled. Presumably, OLE
> Automation provides a ppDisp and then dereferences it back to IDispatch
> which is then marshalled.

OLE Automation isn't going to provide a ppDisp. When it's [out], it's
the IWebBrowser2 object implementation (not OLE Automation) that's
supposed to write a valid interface pointer (or maybe NULL) to *ppDisp,
after which the typelib marshaller will marshal the interface back to
the caller. (And of course, when it's [in], it's the caller that's
supposed to provide a valid interface pointer.)

>  In ITypeInfo::Invoke, there is this code:
> 
>     if (tdesc->vt == VT_PTR)
> 	tdesc = tdesc->u.lptdesc;
> 
> when looping over the arguments (?). So, it seems that this code is
> responsible for dereferencing the pointer, but it only does it once.
> Shouldn't this be a loop to dereference the arg as many times as needed?

VT_DISPATCH is equivalent to IDispatch*, and VT_UNKNOWN is equivalent to
IUnknown*; that is, interface pointers, being interface *pointers*,
already have one level of indirection built in to them (which obviously
helps making the typelib marshaller as complex as it is), so this seems
correct, only one dereference is needed on this level.

> As it is, tdesc->vt ends up being (correctly) VT_DISPATCH but pVarResult
> doesn't seem to be changed....

If the IWebBrowser2 method that's invoked doesn't return an interface,
it's either a bug in the IWebBrowser2 implementation, it failed for some
reason, or perhaps the wrong method was invoked. Or something, I don't
know the exact situation you have.





More information about the wine-devel mailing list