Source code of Windows XP (NT5)
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.

138 lines
3.8 KiB

  1. /*++
  2. Copyright (C) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. DataObj.h
  5. Abstract:
  6. The IDataObject Interface is used to communicate data
  7. --*/
  8. #ifndef __DATAOBJ_H_
  9. #define __DATAOBJ_H_
  10. // Disable 64-bit warnings in atlctl.h
  11. #if _MSC_VER >= 1200
  12. #pragma warning(push)
  13. #endif
  14. #pragma warning ( disable : 4510 )
  15. #pragma warning ( disable : 4610 )
  16. #pragma warning ( disable : 4100 )
  17. #include <atlctl.h>
  18. #if _MSC_VER >= 1200
  19. #pragma warning(pop)
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // Defines, Types etc...
  23. //
  24. class CComponentData; // Forward declaration
  25. typedef enum tagCOOKIETYPE
  26. {
  27. COOKIE_IS_ROOTNODE,
  28. COOKIE_IS_COUNTERMAINNODE,
  29. COOKIE_IS_TRACEMAINNODE,
  30. COOKIE_IS_ALERTMAINNODE,
  31. COOKIE_IS_MYCOMPUTER,
  32. } COOKIETYPE;
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CDataObject - This class is used to pass data back and forth with MMC. It
  35. // uses a standard interface, IDataObject to acomplish this.
  36. // Refer to OLE documentation for a description of clipboard
  37. // formats and the IDataObject interface.
  38. class CDataObject:
  39. public IDataObject,
  40. public CComObjectRoot
  41. {
  42. public:
  43. DECLARE_NOT_AGGREGATABLE(CDataObject)
  44. BEGIN_COM_MAP(CDataObject)
  45. COM_INTERFACE_ENTRY(IDataObject)
  46. END_COM_MAP()
  47. CDataObject();
  48. virtual ~CDataObject();
  49. // IUnknown overrides
  50. STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  51. STDMETHOD_(ULONG, AddRef) ();
  52. STDMETHOD_(ULONG, Release) ();
  53. // IDataObject methods
  54. public:
  55. STDMETHOD(GetDataHere)(FORMATETC *pformatetc, STGMEDIUM *pmedium);
  56. // The rest are not implemented in this sample
  57. STDMETHOD(GetData)(LPFORMATETC /*lpFormatetcIn*/, LPSTGMEDIUM /*lpMedium*/)
  58. { AFX_MANAGE_STATE(AfxGetStaticModuleState());
  59. return E_NOTIMPL;
  60. };
  61. STDMETHOD(EnumFormatEtc)(DWORD /*dwDirection*/, LPENUMFORMATETC* /*ppEnumFormatEtc*/)
  62. { return E_NOTIMPL; };
  63. STDMETHOD(QueryGetData)(LPFORMATETC /*lpFormatetc*/)
  64. { AFX_MANAGE_STATE(AfxGetStaticModuleState());
  65. return E_NOTIMPL;
  66. };
  67. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC /*lpFormatetcIn*/, LPFORMATETC /*lpFormatetcOut*/)
  68. { return E_NOTIMPL; };
  69. STDMETHOD(SetData)(LPFORMATETC/* lpFormatetc */, LPSTGMEDIUM /* lpMedium */, BOOL /* bRelease */)
  70. { return E_NOTIMPL; };
  71. STDMETHOD(DAdvise)(LPFORMATETC /* lpFormatetc */, DWORD /* advf */,
  72. LPADVISESINK /* pAdvSink */, LPDWORD /* pdwConnection */)
  73. { return E_NOTIMPL; };
  74. STDMETHOD(DUnadvise)(DWORD /* dwConnection */)
  75. { return E_NOTIMPL; };
  76. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* /* ppEnumAdvise */)
  77. { return E_NOTIMPL; };
  78. // Non-interface member functions
  79. public:
  80. DATA_OBJECT_TYPES GetContext() { return m_Context; }
  81. COOKIETYPE GetCookieType() { return m_CookieType; }
  82. MMC_COOKIE GetCookie() { return m_ulCookie; }
  83. VOID SetData(MMC_COOKIE ulCookie, DATA_OBJECT_TYPES Type, COOKIETYPE ct);
  84. private:
  85. HRESULT WriteInternal(IStream *pstm);
  86. HRESULT WriteDisplayName(IStream *pstm);
  87. HRESULT WriteMachineName(IStream *pstm);
  88. HRESULT WriteNodeType(IStream *pstm);
  89. HRESULT WriteClsid(IStream *pstm);
  90. ULONG m_cRefs; // Object refcount
  91. MMC_COOKIE m_ulCookie; // What this obj refers to
  92. DATA_OBJECT_TYPES m_Context; // Context in which this was created (Data object type)
  93. COOKIETYPE m_CookieType; // How to interpret m_ulCookie
  94. public:
  95. static UINT s_cfMmcMachineName; // format for machine name when ext. snapin
  96. static UINT s_cfInternal;
  97. static UINT s_cfDisplayName;
  98. static UINT s_cfNodeType;
  99. static UINT s_cfSnapinClsid;
  100. };
  101. #endif // __DATAOBJ_H_