PDA

View Full Version : qt use Invoke function, It is error when I use the DISPATCH_PROPERTYPUT.



mumutou
19th August 2013, 06:01
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.

wysota
19th August 2013, 07:56
How is this problem related to Qt? Apart from qDebug() there is not a single Qt call used in the code you posted.

mumutou
19th August 2013, 08:51
no, when I use the MFC, the error is same