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.

341 lines
12 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. // ***************************************************************************
  5. //
  6. // Original Author: Rajesh Rao
  7. //
  8. // $Author: rajeshr $
  9. // $Date: 6/11/98 4:43p $
  10. // $Workfile:wbemhelp.h $
  11. //
  12. // $Modtime: 6/11/98 11:21a $
  13. // $Revision: 1 $
  14. // $Nokeywords: $
  15. //
  16. //
  17. // Description: Contains the declaration for the CWBEMHelper class. This is
  18. // a class that has many static helper functions pertaining to WBEM
  19. //***************************************************************************
  20. /////////////////////////////////////////////////////////////////////////
  21. #ifndef WBEM_HELPER_H
  22. #define WBEM_HELPER_H
  23. class CWBEMHelper
  24. {
  25. protected:
  26. static LPCWSTR EQUALS_QUOTE;
  27. static LPCWSTR QUOTE;
  28. static LPCWSTR OBJECT_CATEGORY_EQUALS;
  29. static LPCWSTR OBJECT_CLASS_EQUALS;
  30. public:
  31. //***************************************************************************
  32. //
  33. // CWBEMHelper::PutBSTRProperty
  34. //
  35. // Purpose: Puts a BSTR property
  36. //
  37. // Parameters:
  38. // pWbemClass : The WBEM class on which the property has to be put
  39. // strPropertyName : The name of the property to be put
  40. // strPropertyValue : The value of the property to be put
  41. // deallocatePropertyValue : whether to deallocate the parameter strPropertyValue before
  42. // the function returns
  43. //
  44. // Return Value: The COM value representing the return status
  45. //
  46. //***************************************************************************
  47. static HRESULT PutBSTRProperty(IWbemClassObject *pWbemClass,
  48. const BSTR strPropertyName,
  49. BSTR strPropertyValue,
  50. BOOLEAN deallocatePropertyValue = TRUE);
  51. //***************************************************************************
  52. //
  53. // CWBEMHelper::GetBSTRProperty
  54. //
  55. // Purpose: Gets a BSTR property
  56. //
  57. // Parameters:
  58. // pWbemClass : The WBEM class on which the property has to be gotten
  59. // strPropertyName : The name of the property to be gotten
  60. // pStrPropertyValue : The address where the value of the property to should be put
  61. //
  62. // Return Value: The COM value representing the return status. The user should delete the
  63. // string allocated when done
  64. //
  65. //***************************************************************************
  66. static HRESULT GetBSTRProperty(IWbemClassObject *pWbemClass,
  67. const BSTR strPropertyName,
  68. BSTR *pStrPropertyValue);
  69. //***************************************************************************
  70. //
  71. // CWBEMHelper::PutBSTRPropertyT
  72. //
  73. // Purpose: Puts a BSTR property
  74. //
  75. // Parameters:
  76. // pWbemClass : The WBEM class on which the property has to be put
  77. // strPropertyName : The name of the property to be put
  78. // lpszPropertyValue : The value of the property to be put
  79. // deallocatePropertyValue : whether to deallocate the parameter lpszPropertyValue before
  80. // the function returns
  81. //
  82. // Return Value: The COM value representing the return status
  83. //
  84. //***************************************************************************
  85. static HRESULT PutBSTRPropertyT(IWbemClassObject *pWbemClass,
  86. const BSTR strPropertyName,
  87. LPWSTR lpszPropertyValue,
  88. BOOLEAN deallocatePropertyValue = TRUE);
  89. //***************************************************************************
  90. //
  91. // CWBEMHelper::GetBSTRPropertyT
  92. //
  93. // Purpose: Gets a BSTR property
  94. //
  95. // Parameters:
  96. // pWbemClass : The WBEM class on which the property has to be put
  97. // strPropertyName : The name of the property to be put
  98. // lppszPropertyValue : The pointer to LPWSTR where the value of the property will be placed. The user should
  99. // delete this once he is done with it.
  100. //
  101. // Return Value: The COM value representing the return status
  102. //
  103. //***************************************************************************
  104. static HRESULT GetBSTRPropertyT(IWbemClassObject *pWbemClass,
  105. const BSTR strPropertyName,
  106. LPWSTR *lppszPropertyValue);
  107. //***************************************************************************
  108. //
  109. // CWBEMHelper::PutBSTRArrayProperty
  110. //
  111. // Purpose: Puts a BSTR Array property
  112. //
  113. // Parameters:
  114. // pWbemClass : The WBEM class on which the property has to be put
  115. // strPropertyName : The name of the property to be put
  116. // pStrPropertyValue : The array of BSTRS that have the values of the property to be put
  117. // lCount : The number of elements in the above array
  118. // deallocatePropertyValue : whether to deallocate the parameter strPropertyValue before
  119. // the function returns
  120. //
  121. // Return Value: The COM value representing the return status
  122. //
  123. //***************************************************************************
  124. static HRESULT PutBSTRArrayProperty(IWbemClassObject *pWbemClass,
  125. const BSTR strPropertyName,
  126. VARIANT *pVariant);
  127. //***************************************************************************
  128. //
  129. // CWBEMHelper::GetUint8ArrayProperty
  130. //
  131. // Purpose: Gets a VT_UI1 Array property
  132. //
  133. // Parameters:
  134. // pWbemClass : The WBEM class on which the property has to be gotten
  135. // strPropertyName : The name of the property
  136. // ppPropertyValuea : The address of a pointer to BYTE where an array of values will be places
  137. // plCount : The address where the count of elements will be placed
  138. //
  139. // Return Value: The COM value representing the return status. The user should deallocate the array
  140. // returned when done.
  141. //
  142. //***************************************************************************
  143. static HRESULT GetUint8ArrayProperty(IWbemClassObject *pWbemClass,
  144. const BSTR strPropertyName,
  145. LPBYTE *ppPropertyValues,
  146. ULONG *plCount);
  147. //***************************************************************************
  148. //
  149. // CWBEMHelper :: PutBOOLQualifier
  150. //
  151. // Purpose: Puts a BOOLEAN Qualifier
  152. //
  153. // Parameters:
  154. // pQualifierSet : The Qualifier set on which this qualifier has to be put
  155. // strQualifierName : The name of the qualifier to be put
  156. // bQualifierValue : The value of the qualifier to be put
  157. // lFlavour : The flavour of the qualifer
  158. //
  159. // Return Value: The COM value representing the return status
  160. //
  161. //***************************************************************************
  162. static HRESULT PutBOOLQualifier(IWbemQualifierSet *pQualifierSet,
  163. const BSTR strQualifierName,
  164. VARIANT_BOOL bQualifierValue,
  165. LONG lFlavour);
  166. //***************************************************************************
  167. //
  168. // CWBEMHelper :: GetBOOLQualifier
  169. //
  170. // Purpose: Gets a BOOLEAN Qualifier
  171. //
  172. // Parameters:
  173. // pQualifierSet : The Qualifier set on which this qualifier has to be put
  174. // strQualifierName : The name of the qualifier to get
  175. // bQualifierValue : The value of the qualifier to get
  176. // lFlavour : The flavour of the qualifer
  177. //
  178. // Return Value: The COM value representing the return status
  179. //
  180. //***************************************************************************
  181. static HRESULT GetBOOLQualifier(IWbemQualifierSet *pQualifierSet,
  182. const BSTR strQualifierName,
  183. VARIANT_BOOL *pbQualifierValue,
  184. LONG *plFlavour);
  185. //***************************************************************************
  186. //
  187. // CWBEMHelper :: PutI4Qualifier
  188. //
  189. // Purpose: Puts a VT_I4 Qualifier
  190. //
  191. // Parameters:
  192. // pQualifierSet : The Qualifier set on which this qualifier has to be put
  193. // strQualifierName : The name of the qualifier to be put
  194. // lQualifierValue : The value of the qualifier to be put
  195. // lFlavour : The flavour of the qualifer
  196. //
  197. // Return Value: The COM value representing the return status
  198. //
  199. //***************************************************************************
  200. static HRESULT PutI4Qualifier(IWbemQualifierSet *pQualifierSet,
  201. const BSTR strQualifierName,
  202. long lQualifierValue,
  203. LONG lFlavour);
  204. //***************************************************************************
  205. //
  206. // CWBEMHelper :: PutBSTRQualifier
  207. //
  208. // Purpose: Puts a BSTR Qualifier
  209. //
  210. // Parameters:
  211. // pQualifierSet : The Qualifier set on which this qualifier has to be put
  212. // strQualifierName : The name of the qualifier to be put
  213. // strQualifierValue : The value of the qualifier to be put
  214. // lFlavour : The flavour of the qualifer
  215. // deallocateQualifierValue : whether to deallocate the parameter strQualifierValue
  216. // before the function returns
  217. //
  218. // Return Value: The COM value representing the return status
  219. //
  220. //***************************************************************************
  221. static HRESULT PutBSTRQualifier(IWbemQualifierSet *pQualifierSet,
  222. const BSTR strQualifierName,
  223. BSTR strQualifierValue,
  224. LONG lFlavour,
  225. BOOLEAN deallocateQualifierValue = TRUE);
  226. //***************************************************************************
  227. //
  228. // CWBEMHelper :: GetBSTRQualifierT
  229. //
  230. // Purpose: Gets a BSTR Qualifier
  231. //
  232. // Parameters:
  233. // pQualifierSet : The Qualifier set on which this qualifier has to be put
  234. // strQualifierName : The name of the qualifier to be put
  235. // lppszQualifierValue : The address of the LPWSTR where the qualifier value will be put/
  236. // It is the duty of the caller to free this memory when done
  237. // plFlavour : The address where the qualifier flavor will be put. This is optional
  238. //
  239. // Return Value: The COM value representing the return status
  240. //
  241. //***************************************************************************
  242. static HRESULT GetBSTRQualifierT(IWbemQualifierSet *pQualifierSet,
  243. const BSTR strQualifierName,
  244. LPWSTR *lppszQualifierValue,
  245. LONG *plFlavour);
  246. //***************************************************************************
  247. //
  248. // CWBEMHelper :: PutLONGQualifier
  249. //
  250. // Purpose: Puts a LONG Qualifier
  251. //
  252. // Parameters:
  253. // pQualifierSet : The Qualifier set on which this qualifier has to be put
  254. // strQualifierName : The name of the qualifier to be put
  255. // lQualifierValue : The value of the qualifier to be put
  256. // lFlavour : The flavour of the qualifer
  257. //
  258. // Return Value: The COM value representing the return status
  259. //
  260. //***************************************************************************
  261. static HRESULT PutLONGQualifier(IWbemQualifierSet *pQualifierSet,
  262. const BSTR strQualifierName,
  263. LONG lQualifierValue,
  264. LONG lFlavour);
  265. //***************************************************************************
  266. //
  267. // CWBEMHelper :: PutUint8ArrayQualifier
  268. //
  269. // Purpose: Puts a Uint8 array Qualifier
  270. //
  271. // Parameters:
  272. // pQualifierSet : The Qualifier set on which this qualifier has to be put
  273. // strQualifierName : The name of the qualifier to be put
  274. // lpQualifierValue : The value of the qualifier to be put. An array of BYTEs
  275. // dwLenght : The number of elements in the above array
  276. // lFlavour : The flavour of the qualifer
  277. //
  278. // Return Value: The COM value representing the return status
  279. //
  280. //***************************************************************************
  281. static HRESULT PutUint8ArrayQualifier(IWbemQualifierSet *pQualifierSet,
  282. const BSTR strQualifierName,
  283. LPBYTE lpQualifierValue,
  284. DWORD dwLength,
  285. LONG lFlavour);
  286. //***************************************************************************
  287. //
  288. // CWBEMHelper::GetADSIPathFromObjectPath
  289. //
  290. // Purpose: Gets the ADSI Path from an object ref of a WBEM object
  291. //
  292. // Parameters :
  293. // pszObjectRef : The object ref to a WBEM instance
  294. //
  295. // Return Value : The ADSI Path in the key of the object ref. The user should delete this
  296. // when done
  297. //
  298. //***************************************************************************
  299. static LPWSTR GetADSIPathFromObjectPath(LPCWSTR pszObjectRef);
  300. //***************************************************************************
  301. //
  302. // CWBEMHelper::GetObjectRefFromADSIPath
  303. //
  304. // Purpose: Gets the object ref of a WBEM object from its ADSI path
  305. //
  306. // Parameters :
  307. // pszADSIPath : The ADSI path to an ADSI instance
  308. // pszWbemClassName : The WBEM class name of the instance
  309. //
  310. // Return Value : The WBEM object ref of the ADSI instance. The user should delete this
  311. // when done
  312. //
  313. //***************************************************************************
  314. static BSTR GetObjectRefFromADSIPath(LPCWSTR pszADSIPath, LPCWSTR pszWBEMClassName);
  315. static HRESULT FormulateInstanceQuery(IWbemServices *pServices, IWbemContext *pContext, BSTR strClass, IWbemClassObject *pWbemClass, LPWSTR pszObjectCategory, BSTR strClassQualifier, BSTR strCategoryQualifier);
  316. static HRESULT AddSingleCategory(LPWSTR pszObjectCategory, DWORD *pdwOutput, IWbemClassObject *pNextObject, BSTR strClassQualifier, BSTR strCategoryQualifier);
  317. static BOOLEAN IsPresentInBstrList(BSTR *pstrProperyNames, DWORD dwNumPropertyNames, BSTR strPropertyName);
  318. };
  319. #endif /* WBEM_HELPER_H */