Re: Calling COM functions using IDispatch->Invoke(...
- From: "Alf P. Steinbach" <alfps@xxxxxxxx>
- Date: Tue, 22 Apr 2008 23:53:26 +0200
* Alf P. Steinbach:
* 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" );
Sorry, I meant
dp.setParam( 0, L"\C:\\Program Files\..." );
You might need to quote that path since it contains spaces.
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?
.
- Follow-Ups:
- References:
- Calling COM functions using IDispatch->Invoke(...
- From: Alex
- Re: Calling COM functions using IDispatch->Invoke(...
- From: Alf P. Steinbach
- Re: Calling COM functions using IDispatch->Invoke(...
- From: Alex
- Re: Calling COM functions using IDispatch->Invoke(...
- From: Alf P. Steinbach
- Calling COM functions using IDispatch->Invoke(...
- Prev by Date: Re: Calling COM functions using IDispatch->Invoke(...
- Next by Date: CButton: Enable and SetFocus
- Previous by thread: Re: Calling COM functions using IDispatch->Invoke(...
- Next by thread: Re: Calling COM functions using IDispatch->Invoke(...
- Index(es):
Relevant Pages
|