c++ - IDISPATCH::Invoke to call a method fails with error 0x80020005 type mismatch -


I'm trying to call a mthod which takes you two strings here, you are the code < Pre> Miscellaneous Vargas [2]; VariantInit (& amp; vArgs [0]); VariantInit (& amp; vArgs [1]); //VariantInit (& amp; 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.carrgs = 2; DpEntry.cNamedArgs = 0; //dpEntry.rgdispidNamedArgs = New DISPID [2]; //dpEntry.rgdispidNamedArgs[0] = 0; //dpEntry.rgdispidNamedArgs[1] = 1; UINT Index-1 - 1; EXCEPINFO East; Hr = pDisptEntries-> Call (dispid_Add, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, & amp; dpEntry, NULL, & amp; pre, & amp; index);

The error code clearly tells you that the function does not actually take two arguments It is possible that the type string is distorted wrong, it will call the wrong function. Look for return value, do not make sure that when you pass NULL, the function returns a value.

Comments