_IMSegmentEvents_CP.h
资源名称:DELTA_PLC.rar [点击查看]
上传用户:hailongwei
上传日期:2020-11-29
资源大小:5839k
文件大小:2k
源码类别:
单片机开发
开发平台:
Visual C++
- #pragma once
- template<class T>
- class CProxy_IMSegmentEvents :
- public IConnectionPointImpl<T, &__uuidof(_IMSegmentEvents)>
- {
- public:
- HRESULT Fire_OnNotify( LONG Addr)
- {
- HRESULT hr = S_OK;
- T * pThis = static_cast<T *>(this);
- int cConnections = m_vec.GetSize();
- for (int iConnection = 0; iConnection < cConnections; iConnection++)
- {
- pThis->Lock();
- CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
- pThis->Unlock();
- IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
- if (pConnection)
- {
- CComVariant avarParams[1];
- avarParams[0] = Addr; avarParams[0].vt = VT_I4;
- CComVariant varResult;
- DISPPARAMS params = { avarParams, NULL, 1, 0 };
- hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
- }
- }
- return hr;
- }
- HRESULT Fire_OnLink( VARIANT_BOOL LinkStatus)
- {
- HRESULT hr = S_OK;
- T * pThis = static_cast<T *>(this);
- int cConnections = m_vec.GetSize();
- for (int iConnection = 0; iConnection < cConnections; iConnection++)
- {
- pThis->Lock();
- CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
- pThis->Unlock();
- IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
- if (pConnection)
- {
- CComVariant avarParams[1];
- avarParams[0] = LinkStatus; avarParams[0].vt = VT_BOOL;
- CComVariant varResult;
- DISPPARAMS params = { avarParams, NULL, 1, 0 };
- hr = pConnection->Invoke(2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
- }
- }
- return hr;
- }
- };