source: trunk/Utilities/VbsEvents/_IFooEvents_CP.h @ 937

Last change on this file since 937 was 79, checked in by roman, 12 years ago
File size: 852 bytes
Line 
1#pragma once
2
3template<class T>
4class CProxy_IFooEvents :
5        public ATL::IConnectionPointImpl<T, &__uuidof(_IFooEvents)>
6{
7public:
8        HRESULT Fire_Event(BSTR sText)
9        {
10                HRESULT hr = S_OK;
11                T * pThis = static_cast<T *>(this);
12                int cConnections = m_vec.GetSize();
13
14                for (int iConnection = 0; iConnection < cConnections; iConnection++)
15                {
16                        pThis->Lock();
17                        CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
18                        pThis->Unlock();
19
20                        IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
21
22                        if (pConnection)
23                        {
24                                CComVariant avarParams[1];
25                                avarParams[0] = sText;
26                                avarParams[0].vt = VT_BSTR;
27                                DISPPARAMS params = { avarParams, NULL, 1, 0 };
28                                hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &params, NULL, NULL, NULL);
29                        }
30                }
31                return hr;
32        }
33};
34
Note: See TracBrowser for help on using the repository browser.