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.

302 lines
6.9 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // property.h
  6. //
  7. // alanbos 27-Mar-00 Created.
  8. //
  9. // CSWbemProperty and CSWbemPropertySet definitions.
  10. //
  11. //***************************************************************************
  12. #ifndef _PROPERTY_H_
  13. #define _PROPERTY_H_
  14. //***************************************************************************
  15. //
  16. // CLASS NAME:
  17. //
  18. // CSWbemProperty
  19. //
  20. // DESCRIPTION:
  21. //
  22. // Implements the ISWbemProperty interface.
  23. //
  24. //***************************************************************************
  25. class CSWbemProperty : public ISWbemProperty,
  26. public ISupportErrorInfo,
  27. public IProvideClassInfo
  28. {
  29. private:
  30. class CPropertyDispatchHelp : public CDispatchHelp
  31. {
  32. public:
  33. HRESULT HandleError (
  34. DISPID dispidMember,
  35. unsigned short wFlags,
  36. DISPPARAMS FAR* pdispparams,
  37. VARIANT FAR* pvarResult,
  38. UINT FAR* puArgErr,
  39. HRESULT hRes
  40. );
  41. bool HandleNulls (
  42. DISPID dispidMember,
  43. unsigned short wFlags
  44. )
  45. {
  46. return false;
  47. }
  48. };
  49. friend CPropertyDispatchHelp;
  50. CSWbemServices* m_pSWbemServices;
  51. ISWbemInternalObject* m_pSWbemObject;
  52. IWbemClassObject *m_pIWbemClassObject;
  53. CPropertyDispatchHelp m_Dispatch;
  54. BSTR m_name;
  55. CWbemSite *m_pSite;
  56. HRESULT DeleteValuesByHand (
  57. VARIANT & varMatchingValues,
  58. long iFlags,
  59. long iStartIndex,
  60. long iEndIndex
  61. );
  62. HRESULT AddValuesByHand (
  63. VARIANT & varValues,
  64. long iFlags,
  65. long iStartIndex
  66. );
  67. protected:
  68. long m_cRef; //Object reference count
  69. public:
  70. CSWbemProperty (CSWbemServices *pService, ISWbemInternalObject *pObject,
  71. BSTR name);
  72. ~CSWbemProperty (void);
  73. //Non-delegating object IUnknown
  74. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  75. STDMETHODIMP_(ULONG) AddRef(void);
  76. STDMETHODIMP_(ULONG) Release(void);
  77. // IDispatch
  78. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  79. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  80. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  81. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  82. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  83. UINT cNames, LCID lcid, DISPID* rgdispid)
  84. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  85. lcid,
  86. rgdispid);}
  87. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  88. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  89. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  90. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  91. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  92. // ISWbemProperty methods
  93. HRESULT STDMETHODCALLTYPE get_Value
  94. (
  95. /*[out]*/ VARIANT *value
  96. );
  97. HRESULT STDMETHODCALLTYPE put_Value
  98. (
  99. /*[in]*/ VARIANT *value
  100. );
  101. HRESULT STDMETHODCALLTYPE get_Name
  102. (
  103. /*[out]*/ BSTR *name
  104. );
  105. HRESULT STDMETHODCALLTYPE get_IsLocal
  106. (
  107. /*[out]*/ VARIANT_BOOL *local
  108. );
  109. HRESULT STDMETHODCALLTYPE get_Origin
  110. (
  111. /*[out]*/ BSTR *origin
  112. );
  113. HRESULT STDMETHODCALLTYPE get_CIMType
  114. (
  115. /*[out]*/ WbemCimtypeEnum *cimType
  116. );
  117. HRESULT STDMETHODCALLTYPE get_Qualifiers_
  118. (
  119. /*[out]*/ ISWbemQualifierSet **ppQualSet
  120. );
  121. HRESULT STDMETHODCALLTYPE get_IsArray
  122. (
  123. /*[out]*/ VARIANT_BOOL *pIsArray
  124. );
  125. // ISupportErrorInfo methods
  126. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  127. (
  128. /* [in] */ REFIID riid
  129. );
  130. // IProvideClassInfo methods
  131. HRESULT STDMETHODCALLTYPE GetClassInfo
  132. (
  133. /* [in,out] */ ITypeInfo **ppTI
  134. )
  135. {
  136. return m_Dispatch.GetClassInfo (ppTI);
  137. };
  138. // Other Methods
  139. void UpdateEmbedded (VARIANT &var, long index);
  140. void UpdateSite ();
  141. };
  142. //***************************************************************************
  143. //
  144. // CLASS NAME:
  145. //
  146. // CSWbemPropertySet
  147. //
  148. // DESCRIPTION:
  149. //
  150. // Implements the ISWbemPropertySet interface.
  151. //
  152. //***************************************************************************
  153. class CSWbemPropertySet : public ISWbemPropertySet,
  154. public ISupportErrorInfo,
  155. public IProvideClassInfo
  156. {
  157. private:
  158. class CPropertySetDispatchHelp : public CDispatchHelp
  159. {
  160. public:
  161. HRESULT HandleError (
  162. DISPID dispidMember,
  163. unsigned short wFlags,
  164. DISPPARAMS FAR* pdispparams,
  165. VARIANT FAR* pvarResult,
  166. UINT FAR* puArgErr,
  167. HRESULT hRes
  168. );
  169. };
  170. CSWbemServices* m_pSWbemServices;
  171. CSWbemObject* m_pSWbemObject;
  172. IWbemClassObject* m_pIWbemClassObject;
  173. CPropertySetDispatchHelp m_Dispatch;
  174. CWbemSite *m_pSite;
  175. bool m_bSystemProperties;
  176. protected:
  177. long m_cRef; //Object reference count
  178. public:
  179. CSWbemPropertySet (CSWbemServices *pService, CSWbemObject *pObject,
  180. bool bSystemProperties = false);
  181. ~CSWbemPropertySet (void);
  182. //Non-delegating object IUnknown
  183. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  184. STDMETHODIMP_(ULONG) AddRef(void);
  185. STDMETHODIMP_(ULONG) Release(void);
  186. // IDispatch
  187. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  188. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  189. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  190. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  191. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  192. UINT cNames, LCID lcid, DISPID* rgdispid)
  193. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  194. lcid,
  195. rgdispid);}
  196. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  197. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  198. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  199. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  200. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  201. // Collection methods
  202. HRESULT STDMETHODCALLTYPE get__NewEnum
  203. (
  204. /*[out]*/ IUnknown **ppUnk
  205. );
  206. HRESULT STDMETHODCALLTYPE get_Count
  207. (
  208. /*[out]*/ long *plCount
  209. );
  210. HRESULT STDMETHODCALLTYPE Add
  211. (
  212. /*[in]*/ BSTR name,
  213. /*[in]*/ WbemCimtypeEnum cimType,
  214. /*[in]*/ VARIANT_BOOL isArray,
  215. /*[in]*/ long lFlags,
  216. /*[out]*/ ISWbemProperty **ppProperty
  217. );
  218. HRESULT STDMETHODCALLTYPE Item
  219. (
  220. /*[in]*/ BSTR Name,
  221. /*[in]*/ long lFlags,
  222. /*[out]*/ ISWbemProperty **ppProperty
  223. );
  224. HRESULT STDMETHODCALLTYPE Remove
  225. (
  226. /*[in]*/ BSTR Name,
  227. /*[in]*/ long lFlags
  228. );
  229. // ISWbemPropertySet methods
  230. HRESULT STDMETHODCALLTYPE BeginEnumeration
  231. (
  232. );
  233. HRESULT STDMETHODCALLTYPE Next
  234. (
  235. /*[in]*/ long lFlags,
  236. /*[out]*/ ISWbemProperty **ppProperty
  237. );
  238. // ISupportErrorInfo methods
  239. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  240. (
  241. /* [in] */ REFIID riid
  242. );
  243. // IProvideClassInfo methods
  244. HRESULT STDMETHODCALLTYPE GetClassInfo
  245. (
  246. /* [in,out] */ ITypeInfo **ppTI
  247. )
  248. {
  249. return m_Dispatch.GetClassInfo (ppTI);
  250. };
  251. };
  252. #endif