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.

84 lines
2.5 KiB

  1. // DeviceAction.h : Declaration of the CDeviceAction
  2. #ifndef __DEVICEACTION_H_
  3. #define __DEVICEACTION_H_
  4. #include "resource.h" // main symbols
  5. #include "ioblockdefs.h"
  6. template <class T>
  7. class CProxy_IDeviceActionEvent : public IConnectionPointImpl<T, &DIID__IDeviceActionEvent, CComDynamicUnkArray>
  8. {
  9. public:
  10. HRESULT Fire_DeviceActionEvent()
  11. {
  12. CComVariant varResult;
  13. T* pT = static_cast<T*>(this);
  14. int nConnectionIndex;
  15. int nConnections = m_vec.GetSize();
  16. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  17. {
  18. pT->Lock();
  19. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  20. pT->Unlock();
  21. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  22. if (pDispatch != NULL)
  23. {
  24. VariantClear(&varResult);
  25. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  26. pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
  27. }
  28. }
  29. return varResult.scode;
  30. }
  31. };
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CDeviceAction
  34. class ATL_NO_VTABLE CDeviceAction :
  35. public CComObjectRootEx<CComSingleThreadModel>,
  36. public CComCoClass<CDeviceAction, &CLSID_DeviceAction>,
  37. public IConnectionPointContainerImpl<CDeviceAction>,
  38. public IDispatchImpl<IDeviceAction, &IID_IDeviceAction, &LIBID_WIAFBLib>,
  39. public CProxy_IDeviceActionEvent< CDeviceAction >,
  40. public IObjectSafetyImpl<CDeviceAction, INTERFACESAFE_FOR_UNTRUSTED_CALLER>
  41. {
  42. public:
  43. SCANSETTINGS *m_pScannerSettings;
  44. LONG m_DeviceActionID;
  45. LONG m_DeviceValueID;
  46. LONG m_lValue;
  47. CDeviceAction()
  48. {
  49. m_DeviceActionID = 0;
  50. m_DeviceValueID = 0;
  51. }
  52. DECLARE_REGISTRY_RESOURCEID(IDR_DEVICEACTION)
  53. DECLARE_PROTECT_FINAL_CONSTRUCT()
  54. BEGIN_COM_MAP(CDeviceAction)
  55. COM_INTERFACE_ENTRY(IDeviceAction)
  56. COM_INTERFACE_ENTRY(IDispatch)
  57. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  58. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  59. END_COM_MAP()
  60. BEGIN_CONNECTION_POINT_MAP(CDeviceAction)
  61. CONNECTION_POINT_ENTRY(DIID__IDeviceActionEvent)
  62. END_CONNECTION_POINT_MAP()
  63. // IDeviceAction
  64. public:
  65. STDMETHOD(get_Value)(VARIANT* pvValue);
  66. STDMETHOD(put_Value)(VARIANT* pvValue);
  67. STDMETHOD(Action)(LONG *plActionID);
  68. STDMETHOD(ValueID)(LONG *plValueID);
  69. };
  70. #endif //__DEVICEACTION_H_