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.

80 lines
2.3 KiB

  1. #ifndef _WIAEVENTSCP_H_
  2. #define _WIAEVENTSCP_H_
  3. template <class T>
  4. class CProxy_IWiaEvents : public IConnectionPointImpl<T, &DIID__IWiaEvents, CComDynamicUnkArray>
  5. {
  6. //Warning this class may be recreated by the wizard.
  7. public:
  8. VOID Fire_OnDeviceConnected(BSTR bstrDeviceId)
  9. {
  10. T* pT = static_cast<T*>(this);
  11. int nConnectionIndex;
  12. CComVariant* pvars = new CComVariant[1];
  13. int nConnections = m_vec.GetSize();
  14. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  15. {
  16. pT->Lock();
  17. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  18. pT->Unlock();
  19. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  20. if (pDispatch != NULL)
  21. {
  22. pvars[0] = bstrDeviceId;
  23. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  24. pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  25. }
  26. }
  27. delete[] pvars;
  28. }
  29. VOID Fire_OnDeviceDisconnected(BSTR bstrDeviceId)
  30. {
  31. T* pT = static_cast<T*>(this);
  32. int nConnectionIndex;
  33. CComVariant* pvars = new CComVariant[1];
  34. int nConnections = m_vec.GetSize();
  35. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  36. {
  37. pT->Lock();
  38. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  39. pT->Unlock();
  40. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  41. if (pDispatch != NULL)
  42. {
  43. pvars[0] = bstrDeviceId;
  44. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  45. pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  46. }
  47. }
  48. delete[] pvars;
  49. }
  50. VOID Fire_OnTransferComplete(IDispatch * pItem, BSTR bstrPath)
  51. {
  52. T* pT = static_cast<T*>(this);
  53. int nConnectionIndex;
  54. CComVariant* pvars = new CComVariant[2];
  55. int nConnections = m_vec.GetSize();
  56. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  57. {
  58. pT->Lock();
  59. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  60. pT->Unlock();
  61. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  62. if (pDispatch != NULL)
  63. {
  64. pvars[1] = pItem;
  65. pvars[0] = bstrPath;
  66. DISPPARAMS disp = { pvars, NULL, 2, 0 };
  67. HRESULT hr = THR( pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL) );
  68. }
  69. }
  70. delete[] pvars;
  71. }
  72. };
  73. #endif