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.

318 lines
7.3 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997.
  5. //
  6. // File: dataobj.hxx
  7. //
  8. // Contents: Class that implements IDataObject interface
  9. //
  10. // Classes: CDataObject
  11. //
  12. // History: 12-05-1996 DavidMun Created
  13. //
  14. //---------------------------------------------------------------------------
  15. #ifndef __DATAOBJ_HXX_
  16. #define __DATAOBJ_HXX_
  17. //+--------------------------------------------------------------------------
  18. //
  19. // Class: CDataObject (do)
  20. //
  21. // Purpose: Implement the IDataObject interface.
  22. //
  23. // History: 1-23-1997 davidmun Created
  24. //
  25. //---------------------------------------------------------------------------
  26. class CDataObject: public IDataObject
  27. {
  28. public:
  29. //
  30. // IUnknown overrides
  31. //
  32. STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  33. STDMETHOD_(ULONG, AddRef) ();
  34. STDMETHOD_(ULONG, Release) ();
  35. //
  36. // IDataObject overrides
  37. //
  38. STDMETHOD(GetData) (FORMATETC *pformatetcIn,
  39. STGMEDIUM *pmedium);
  40. STDMETHOD(GetDataHere) (FORMATETC *pformatetc,
  41. STGMEDIUM *pmedium);
  42. STDMETHOD(QueryGetData) (FORMATETC *pformatetc);
  43. STDMETHOD(GetCanonicalFormatEtc) (FORMATETC *pformatectIn,
  44. FORMATETC *pformatetcOut);
  45. STDMETHOD(SetData) (FORMATETC *pformatetc,
  46. STGMEDIUM *pmedium,
  47. BOOL fRelease);
  48. STDMETHOD(EnumFormatEtc) (DWORD dwDirection,
  49. IEnumFORMATETC **ppenumFormatEtc);
  50. STDMETHOD(DAdvise) (FORMATETC *pformatetc,
  51. DWORD advf,
  52. IAdviseSink *pAdvSink,
  53. DWORD *pdwConnection);
  54. STDMETHOD(DUnadvise) (DWORD dwConnection);
  55. STDMETHOD(EnumDAdvise) (IEnumSTATDATA **ppenumAdvise);
  56. //
  57. // Non-interface member functions
  58. //
  59. CDataObject();
  60. ~CDataObject();
  61. VOID
  62. SetCookie(
  63. MMC_COOKIE Cookie,
  64. DATA_OBJECT_TYPES Type,
  65. COOKIETYPE ct);
  66. DATA_OBJECT_TYPES
  67. GetContext();
  68. COOKIETYPE
  69. GetCookieType();
  70. MMC_COOKIE
  71. GetCookie();
  72. VOID
  73. SetComponentData(
  74. CComponentData *pcd);
  75. //
  76. // Public data members
  77. //
  78. static const UINT s_cfInternal; // custom clipboard format
  79. static const UINT s_cfMachineName; // server focus
  80. static const UINT s_cfImportViews; // public fmt we ask for when acting
  81. // as an extension
  82. private:
  83. HRESULT
  84. _WriteClsid(
  85. IStream *pstm);
  86. HRESULT
  87. _WriteDisplayName(
  88. IStream *pstm);
  89. HRESULT
  90. _WriteResultRecNo(
  91. IStream *pstm);
  92. HRESULT
  93. _WriteResultRecord(
  94. IStream *pstm);
  95. HRESULT
  96. _WriteScopeAbbrev(
  97. IStream *pstm);
  98. HRESULT
  99. _WriteScopeFilter(
  100. IStream *pstm);
  101. HRESULT
  102. _WriteInternal(
  103. IStream *pstm);
  104. HRESULT
  105. _WriteNodeType(
  106. IStream *pstm);
  107. HRESULT
  108. _WriteNodeId2(
  109. LPSTGMEDIUM pmedium);
  110. HRESULT
  111. _WriteNodeTypeString(
  112. IStream *pstm);
  113. CDllRef _DllRef; // inc/dec dll object count
  114. ULONG _cRefs; // object refcount
  115. MMC_COOKIE _Cookie; // what this obj refers to
  116. DATA_OBJECT_TYPES _Context; // context in which this was created
  117. COOKIETYPE _Type; // how to interpret _Cookie
  118. CComponentData *_pcd; // NULL if created by csnapin
  119. public:
  120. //
  121. // Clipboard formats used with GetDataHere. See also some formats
  122. // declared in the public section.
  123. //
  124. static const UINT s_cfNodeType;
  125. static const UINT s_cfNodeId2;
  126. static const UINT s_cfNodeTypeString;
  127. static const UINT s_cfDisplayName;
  128. static const UINT s_cfSnapinClsid;
  129. static const UINT s_cfSnapinPreloads;
  130. static const UINT s_cfExportScopeAbbrev;
  131. static const UINT s_cfExportScopeFilter;
  132. static const UINT s_cfExportResultRecNo;
  133. };
  134. //+--------------------------------------------------------------------------
  135. //
  136. // Member: CDataObject::GetContext
  137. //
  138. // Synopsis: Return value indicating context under which this data object
  139. // was created.
  140. //
  141. // History: 12-11-1996 DavidMun Created
  142. //
  143. //---------------------------------------------------------------------------
  144. inline DATA_OBJECT_TYPES
  145. CDataObject::GetContext()
  146. {
  147. return _Context;
  148. }
  149. //+--------------------------------------------------------------------------
  150. //
  151. // Member: CDataObject::GetCookieType
  152. //
  153. // Synopsis: Return the type of cookie contained within this object.
  154. //
  155. // History: 1-23-1997 davidmun Created
  156. //
  157. //---------------------------------------------------------------------------
  158. inline COOKIETYPE
  159. CDataObject::GetCookieType()
  160. {
  161. return _Type;
  162. }
  163. //+--------------------------------------------------------------------------
  164. //
  165. // Member: CDataObject::GetCookie
  166. //
  167. // Synopsis: Return cookie for this object.
  168. //
  169. // History: 12-11-1996 DavidMun Created
  170. //
  171. // Notes: CAUTION: if cookie is a CLogInfo, caller must AddRef it
  172. // to keep it.
  173. //
  174. //---------------------------------------------------------------------------
  175. inline MMC_COOKIE
  176. CDataObject::GetCookie()
  177. {
  178. return _Cookie;
  179. }
  180. //+--------------------------------------------------------------------------
  181. //
  182. // Member: CDataObject::SetComponentData
  183. //
  184. // Synopsis: Store back pointer to parent component data object.
  185. //
  186. // History: 3-12-1997 DavidMun Created
  187. //
  188. // Notes: If the data object was created by a CSnapin object, this
  189. // method will never be called.
  190. //
  191. //---------------------------------------------------------------------------
  192. inline VOID
  193. CDataObject::SetComponentData(
  194. CComponentData *pcd)
  195. {
  196. _pcd = pcd;
  197. }
  198. //+--------------------------------------------------------------------------
  199. //
  200. // Member: CDataObject::_WriteClsid
  201. //
  202. // Synopsis: Write this snapin's clsid into [pstm].
  203. //
  204. // History: 06-09-1997 DavidMun Created
  205. //
  206. //---------------------------------------------------------------------------
  207. inline HRESULT
  208. CDataObject::_WriteClsid(
  209. IStream *pstm)
  210. {
  211. HRESULT hr;
  212. hr = pstm->Write(&CLSID_EventLogSnapin,
  213. sizeof CLSID_EventLogSnapin,
  214. NULL);
  215. CHECK_HRESULT(hr);
  216. return hr;
  217. }
  218. //+--------------------------------------------------------------------------
  219. //
  220. // Member: CDataObject::_WriteInternal
  221. //
  222. // Synopsis: Write this object's data in the private clipboard format
  223. // to the stream [pstm].
  224. //
  225. // History: 06-09-1997 DavidMun Created
  226. //
  227. //---------------------------------------------------------------------------
  228. inline HRESULT
  229. CDataObject::_WriteInternal(
  230. IStream *pstm)
  231. {
  232. HRESULT hr;
  233. CDataObject *pThis = this;
  234. hr = pstm->Write(&pThis, sizeof (CDataObject *), NULL);
  235. CHECK_HRESULT(hr);
  236. return hr;
  237. }
  238. #endif // __DATAOBJ_HXX_