Re: Calling COM functions using IDispatch->Invoke(...
* Alex:
Alf,
I tried to implement your class,
But it also fails, could you please check out what I?m doing wrong:
SomeCOMObject pComObj; //of course I?ve changed in the constructor
//PROG ID
alfs::DispatchParams dp( 2 );
DISPPARAMS* pDispParam = dp.ptr();
pDispParam->cArgs = 2;
pDispParam->cNamedArgs = 0;
Uh huh. You shouldn't do anything with the innards of the parameters object.
But as it happens it looks like the above does nothing, just assigning the
values that are already there.
Simply don't do anything.
DISPID dispidNamed = DISPATCH_METHOD;
pDispParam->rgdispidNamedArgs = &dispidNamed;
Oops.
Simply don't do anything.
//or
pDispParam->rgdispidNamedArgs = NULL
//as Sven suggested
This is also bad.
Simply don't do anything.
pDispParam->rgvarg = new VARIANTARG[ 2 ];
pDispParam->rgvarg[ 0 ].vt = VT_ERROR;
pDispParam->rgvarg[ 0 ].lVal = DISP_E_PARAMNOTFOUND;
pDispParam->rgvarg[ 1 ].vt = VT_BSTR;
pDispParam->rgvarg[ 1 ].bstrVal = SysAllocString( L"C:\\Program Files\
\... " );
Ditto, simply don't do anything.
Instead,
dp.setParam( 0, L"Start" );
pComObj.call( L"Start", dp );
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?