COM, ATL

디스패치 구현부...참조

디버그정 2008. 8. 14. 06:50

I currently used a dirty fix and I'm passing every parameter trough as a
double value in the variant, this seems to work for me (compiler gives a
warning about a pointer cast to a double about loosing data but still
seems to work).

This is my IDispatch implementation:

STDMETHODIMP CustomFilter::GetTypeInfoCount(UINT * pctinfo) {
if (pctinfo == NULL)
return E_INVALIDARG;
*pctinfo = 1;
return NO_ERROR;
}

STDMETHODIMP CustomFilter::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo
** ppTInfo) {
return E_INVALIDARG;
}

STDMETHODIMP CustomFilter::GetIDsOfNames(REFIID riid, LPOLESTR *
rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId) {
if(!IsEqualIID(riid, IID_NULL))
return DISP_E_UNKNOWNINTERFACE;

if (wcscmp(rgszNames[0], L"Param1") == 0)
rgDispId[0] = 1;
else if (wcscmp(rgszNames[0], L"Param2") == 0)
rgDispId[0] = 2;
else if (wcscmp(rgszNames[0], L"Param3") == 0)
rgDispId[0] = 3;
else
return DISP_E_UNKNOWNNAME;
return NO_ERROR;
}

STDMETHODIMP CustomFilter::Invoke(DISPID dispIdMember, REFIID riid, LCID
lcid, WORD wFlags, DISPPARAMS * pDispParams, VARIANT * pVarResult,
EXCEPINFO * pExcepInfo, UINT * puArgErr) {
if (wFlags & DISPATCH_PROPERTYPUT && pDispParams->cArgs == 1) {
switch (dispIdMember) {
case 1: //param1 is a float
setParam1(float(pDispParams[0].rgvarg->dblVal));
break;
case 2: //param2 is a pointer
setParam2((void *) long long(pDispParams[0].rgvarg->dblVal));
break;
case 3: //param3 is an int
setParam3(int(pDispParams[0].rgvarg->dblVal));
break;
}
}
return NO_ERROR;
}

'COM, ATL' 카테고리의 다른 글

자동화 타입(BSTR, VARIANT, SAFEARRAY, UDT)  (0) 2008.08.14
Why type library marshaling?  (0) 2008.08.14
COM Architecture : Interface Marshaling, IDispatch interface  (0) 2008.08.14
HRESULT  (2) 2008.08.13
컴포넌트 관련 define 문  (0) 2008.08.13
Silan Liu의 COM과 ATL.html  (0) 2008.08.13
REGSVR32 사용법  (0) 2008.08.12