I need help calling Invoke to get a specific prop get method.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using ATL and the class wizard to define an interface that has methods and properties. I also am writing test code to use IDispatch::Invoke to test the APIs in the interface. I have one property whose get function I cannot seem to call. It has the same signature as another property for which I can call Invoke on the prop get API. Can someone tell me what is wrong? When I call Invoke, I get back error 0x80020004 (parameter not found) with the parameter being arg zero (the only arg to the method). My call to GetIDsOfNames correctly returns the dispatch id of 4. interface IAutoGrabber : IDispatch
{
[propget, id(2), helpstring("Name of application.")] HRESULT ApplicationName([out, retval] BSTR* pVal);
[propget, id(3), helpstring("Name of top level document.")] HRESULT TopLevelDocumentName([out, retval] BSTR* pVal);
[propget, id(4), helpstring("Encoding flag.")]HRESULT Base64EncodingFlag([out, retval] long* pVal);
[propput, id(4), helpstring("Encoding flag.")] HRESULT Base64EncodingFlag([in] long newVal);
[propget, id(5), helpstring("Number of files to be uploaded.")] HRESULT NumberOfFilesToUpload([out, retval] LONG* pVal);
[id(6), helpstring("Open the next file to be uploaded.")] HRESULT open_stream([in] long stream_index );
[propget, id(7), helpstring("Returns whether the current file being uploaded has been completely processed.")] HRESULT is_stream_eof([out, retval] VARIANT_BOOL* pVal);
[id(8), helpstring("Read next buffer of data from file and encodes the data.")] HRESULT read_stream([out,retval] BSTR* EncodedData);
};
My call to Invoke follows. Apparently I am not filling in the disp params correctly I have tried other types besides VT_I4 to no avail.HRESULT SetEncodeFlag( LPDISPATCH pDispatch, LONG nFlag )
{
HRESULT hr = NOERROR;
try
{
UINT uErr = 0;
if( pDispatch )
{
DISPID rgDispId = 0;
OLECHAR *Names[1] = {L"Base64EncodingFlag"};
hr = pDispatch->GetIDsOfNames( IID_NULL,
Names,
1,
LOCALE_USER_DEFAULT,
&rgDispId );
if( SUCCEEDED(hr) )
{
VARIANTARG pvars[1];
VariantInit(&pvars[0]);
pvars[0].vt = VT_I4;
pvars[0].intVal = 0;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
hr = pDispatch->Invoke( rgDispId,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYPUT,
&disp,
NULL,
NULL,
&uErr );
}
}
else
{
hr = E_INVALIDARG;
}
}
catch(_com_error &e)
{
hr = e.Error();
}
return hr;
}
Does anyone see what I have done incorrectly?
R.D. Holland

View the full article
 
Back
Top