
Originally Posted by
TAPCON
Analysing with typelib information the method createElement gives a vartype of 9 (VT_DISPATCH) for the return value.
Here is the relevant IDL from C:\Windows\SysWOW64\msxml6.dll
Code:
[
odl,
uuid(2933BF81-7B36-11D2-B20E-00C04F983E60),
hidden,
dual,
nonextensible,
oleautomation
]
interface IXMLDOMDocument : IXMLDOMNode {
[id(0x00000026), propget, helpstring("node corresponding to the DOCTYPE")]
HRESULT doctype([out, retval] IXMLDOMDocumentType** documentType);
[id(0x00000027), propget, helpstring("info on this DOM implementation")]
HRESULT implementation([out, retval] IXMLDOMImplementation** impl);
[id(0x00000028), propget, helpstring("the root of the tree")]
HRESULT documentElement([out, retval] IXMLDOMElement** DOMElement);
[id(0x00000028), propputref, helpstring("the root of the tree")]
HRESULT documentElement([in] IXMLDOMElement* DOMElement);
[id(0x00000029), helpstring("create an Element node")]
HRESULT createElement(
[in] BSTR tagName,
[out, retval] IXMLDOMElement** element);
. . .
and apparently createElement *is* returning an HRESULT.

Originally Posted by
TAPCON
So I suggest to to call DispCallFunc with return vartype 9 but this is not working. I always get the return error &H80020010 of DispCallFunc. Even if I use some modifications of return type, I do not get an error free call of DispCallFunc.
Obviously using the createElement function returns a IDispatch object reference in VB6.
So my question is, what are the correct settings for DispCallFunc to call createElement withou any errors?
You cannot use DispCallFunc API directly as an errorless version of the built-in CallByName, a version that does not raise any errors as returned in the HRESULT. This would require manually calling IDispatch::Invoke as LaVolpe has shown in previous posts here.
For an errorless direct replacement of the built-in CallByName you can take a look at this DispInvoke function that uses DispCallFunc for the heavy lifting too.
cheers,
</wqw>