PDA

View Full Version : QAxObject, problem with VARIANT* parameter



jack_0x666
10th June 2015, 13:41
Hi,
I've got a problem with an ActiveX. I can successfully call functions except those with a VARIANT* parameter. I will take the GetMPStepMessages function as example.
When calling the documentation() function on the ActiveX, it returns this:


Call the function directly:
QVAriantList params = ...
bool result = object->dynamicCall("GetMPStepMessages(QVariant&)", params).toBool();

I try to call this function exactly like this, but it returns this error message:
"Error calling IDispatch member GetMPStepMessages: type mismatch in parameter 0"

Second try, i generate the class with the dumcpp tool from Qt. But same error: "type mismatch in parameter 0." I try with a QVariant, QVariantList, ... but same problem.

Debuging the dynamicCall() function, it shows that it is a wrapper around the IDispatch::Invoke method. https://msdn.microsoft.com/en-us/library/windows/desktop/ms221479(v=vs.85).aspx
When the dynamicCall function is called with a QVariant containing a QVariantList as parameter, the invoke method (in qaxobject.cpp) is called with a VARIANT wich is of type VT_BOOL | VT_BYREF, wich obviously is wrong because there is no BOOL in my parameters.

Then, i successfully manage to call this function, but directly with the IDispatch::invoke method by myself. To works, the VARIANT parameters must have the type VT_VARIANT | VT_BYREF.

So my question is, why Qt failed to transform a QVariant to a VARIANT with type of VT_VARIANT | VT_BYREF. Is it a bug?

Maybe it should help, so here is the call in VC++:


BOOL GetMPStepMessages(VARIANT* vArray)
{
BOOL result;
static BYTE parms[] = VTS_PVARIANT;
InvokeHelper(0x14, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, vArray);
return result;
}

Thanks.