我试图在这里调用一个带2个字符串的方法,你就是代码
VARIANT vArgs[2];
VariantInit(&vArgs[0]);
VariantInit(&vArgs[1]);
//VariantInit(&vArgs[2]);
//vArgs[2].pdispVal = pDisptEntries;
vArgs[1].bstrVal = bstrSrc;
vArgs[0].bstrVal = bstrtrgt;
vArgs[0].vt = VT_BSTR;
vArgs[1].vt = VT_BSTR;
//vArgs[2].vt = VT_DISPATCH;
dpEntry.rgvarg = vArgs;
dpEntry.cArgs = 2;
dpEntry.cNamedArgs = 0;
//dpEntry.rgdispidNamedArgs = new DISPID[2];
//dpEntry.rgdispidNamedArgs[0] = 0;
//dpEntry.rgdispidNamedArgs[1] = 1;
UINT index = -1;
EXCEPINFO ex;
hr = pDisptEntries->Invoke(dispid_Add, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpEntry, NULL, &ex, &index);
答案 0 :(得分:1)
错误代码明确地告诉您该函数实际上没有采用string类型的两个参数。也可能出现错误,它会调用错误的函数。注意返回值,不确定传递NULL时会发生什么,但函数返回一个值。