when I use the Qt to Invoke with DISPATCH_PROPERTYPUT, is error.
next is my code:
void CFoxitPDFSDK::SetProperty(DISPID id, VARTYPE put_type, QString put_value) {
IDispatch *iface = createIDispatch();
if (iface) {
VARIANT arg[1];
arg[0].vt = put_type;
if(put_type == VT_I4) {
arg[0].lVal = put_value.toLong();
qDebug() << put_value.toLong();
} else if(put_type == VT_BSTR) {
}
// EXCEPINFO* e = new EXCEPINFO;
DISPPARAMS dispparams = {arg, &dispidNamed, 1, 1};
/* dispparams.cNamedArgs = 1;
dispparams.rgdispidNamedArgs = &dispidNamed;*/
HRESULT hresult = iface->Invoke(id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
if(hresult == S_OK) {
} else {
qDebug() << __FUNCTION__ << __LINE__ << hresult;
qDebug() << DISP_E_BADPARAMCOUNT << "DISP_E_BADPARAMCOUNT";
qDebug() << DISP_E_BADVARTYPE << "DISP_E_BADVARTYPE";
qDebug() << DISP_E_EXCEPTION << "DISP_E_EXCEPTION";
qDebug() << DISP_E_MEMBERNOTFOUND << "DISP_E_MEMBERNOTFOUND";
qDebug() << DISP_E_NONAMEDARGS << "DISP_E_NONAMEDARGS";
qDebug() << DISP_E_OVERFLOW << "DISP_E_OVERFLOW";
qDebug() << DISP_E_PARAMNOTFOUND << "DISP_E_PARAMNOTFOUND";
qDebug() << DISP_E_TYPEMISMATCH << "DISP_E_TYPEMISMATCH";
qDebug() << DISP_E_UNKNOWNINTERFACE << "DISP_E_UNKNOWNINTERFACE";
qDebug() << DISP_E_UNKNOWNLCID << "DISP_E_UNKNOWNLCID";
qDebug() << DISP_E_PARAMNOTOPTIONAL << "DISP_E_PARAMNOTOPTIONAL";
// qDebug() << QString::fromUtf16((const ushort*)e->bstrSource);
// qDebug() << QString::fromUtf16((const ushort*)e->bstrDescription);
}
releaseIDispatch(iface);
}
}
error is DISP_E_EXCEPTION .
when I don't add
DISPPARAMS dispparams = {arg, &dispidNamed, 1, 1};
/* dispparams.cNamedArgs = 1;
dispparams.rgdispidNamedArgs = &dispidNamed;*/
the error is DISP_E_PARAMNOTOPTIONAL
when I use the DISPATCH_PROPERTYGET, and DISPATCH_METHOD is ok.
DISPID dispidNamed = DISPID_PROPERTYPUT; I defined it.
Bookmarks