Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.2 KiB

  1. // Copyright (c) 1999-2002 Microsoft Corporation. All Rights Reserved.
  2. #pragma once
  3. #ifndef _MSVIDDEVICEEVENT_H_
  4. #define _MSVIDDEVICEEVENT_H_
  5. template <class T, const IID* piid = &IID_IMSVidDeviceEvent, class CDV = CComDynamicUnkArray>
  6. class CProxy_DeviceEvent : public IConnectionPointImpl<T, piid, CDV>
  7. {
  8. public:
  9. void Fire_VoidMethod(DISPID eventid) {
  10. T* pT = static_cast<T*>(this);
  11. int nConnectionIndex;
  12. int nConnections = m_vec.GetSize();
  13. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  14. {
  15. pT->Lock();
  16. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  17. pT->Unlock();
  18. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  19. if (pDispatch != NULL)
  20. {
  21. HRESULT hr;
  22. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  23. hr = pDispatch->Invoke(eventid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  24. if(FAILED(hr)){
  25. TRACELSM(TRACE_ERROR, (dbgDump << "CProxy_DeviceEvent::Fire_VoidMethod() Eventid " << eventid << "Invoke " << nConnectionIndex << " failed hr = " << hexdump(hr)), "");
  26. }
  27. }
  28. }
  29. }
  30. void Fire_StateChange(IMSVidDevice *lpd, long oldState, long newState)
  31. {
  32. T* pT = static_cast<T*>(this);
  33. int nConnectionIndex;
  34. CComVariant* pvars = new CComVariant[3];
  35. int nConnections = m_vec.GetSize();
  36. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  37. {
  38. pT->Lock();
  39. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  40. pT->Unlock();
  41. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  42. if (pDispatch != NULL)
  43. {
  44. pvars[0] = lpd;
  45. pvars[1] = oldState;
  46. pvars[2] = newState;
  47. DISPPARAMS disp = { pvars, NULL, 3, 0 };
  48. pDispatch->Invoke(eventidStateChange, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  49. }
  50. }
  51. delete[] pvars;
  52. }
  53. };
  54. #endif