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.5 KiB

  1. #ifndef _MWMIOBJECT_H
  2. #define _MWMIOBJECT_H
  3. //
  4. // Copyright (c) Microsoft. All Rights Reserved
  5. //
  6. // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Microsoft.
  7. // The copyright notice above does not evidence any
  8. // actual or intended publication of such source code.
  9. //
  10. // OneLiner : MWmiObject interface.
  11. // DevUnit : wlbstest
  12. // Author : Murtaza Hakim
  13. //
  14. // Description:
  15. // -----------
  16. // include files
  17. //
  18. #include "MWMIInstance.h"
  19. #include "MWMIDefs.h"
  20. #include <wbemidl.h>
  21. #include <comdef.h>
  22. #include <vector>
  23. using namespace std;
  24. class MWmiObject
  25. {
  26. public:
  27. enum MWmiObject_Error
  28. {
  29. MWmiObject_SUCCESS = 0,
  30. CONNECT_FAILED = 1,
  31. COM_FAILURE = 2,
  32. NO_SUCH_OBJECT = 3,
  33. NO_SUCH_PARAMETER = 4,
  34. NO_SUCH_PATH = 5,
  35. };
  36. //
  37. // Description:
  38. // -----------
  39. // constructor.
  40. //
  41. // Parameters:
  42. // ----------
  43. // ipAddr IN : ip address of machine to contact.
  44. // nameSpace IN : namespace to connect to.
  45. // loginName IN : name to log as.
  46. // passWord IN : password to use.
  47. //
  48. // Returns:
  49. // -------
  50. // none.
  51. MWmiObject( const _bstr_t& ipAddr,
  52. const _bstr_t& nameSpace,
  53. const _bstr_t& loginName,
  54. const _bstr_t& passWord );
  55. //
  56. // Description:
  57. // -----------
  58. // constructor for connecting to local machine.
  59. //
  60. // Parameters:
  61. // ----------
  62. // nameSpace IN : namespace to connect to.
  63. //
  64. // Returns:
  65. // -------
  66. // none.
  67. MWmiObject( const _bstr_t& nameSpace );
  68. //
  69. // Description:
  70. // -----------
  71. // copy constructor.
  72. //
  73. // Parameters:
  74. // ----------
  75. // mwmiobj IN : object to copy.
  76. //
  77. // Returns:
  78. // -------
  79. // none.
  80. MWmiObject( const MWmiObject& mwmiobj );
  81. //
  82. // Description:
  83. // -----------
  84. // assignment operator.
  85. //
  86. // Parameters:
  87. // ----------
  88. // rhs IN : obj to assign.
  89. //
  90. // Returns:
  91. // -------
  92. // self.
  93. MWmiObject&
  94. MWmiObject::operator=(const MWmiObject& rhs );
  95. //
  96. // Description:
  97. // -----------
  98. // destructor.
  99. //
  100. // Parameters:
  101. // ----------
  102. // none
  103. //
  104. // Returns:
  105. // -------
  106. // none
  107. ~MWmiObject();
  108. //
  109. // Description:
  110. // -----------
  111. // gets instances of a particular class.
  112. //
  113. // Parameters:
  114. // ----------
  115. // objectToGetInstancesOf IN : class whose instances to be retrieved.
  116. // instanceStore OUT : vector containing instances.
  117. //
  118. // Returns:
  119. // -------
  120. // SUCCESS else errorcode
  121. MWmiObject_Error
  122. getInstances(
  123. const _bstr_t& objectToGetInstancesOf,
  124. vector< MWmiInstance >* instanceStore );
  125. //
  126. // Description:
  127. // -----------
  128. // gets instances of a particular class having specific __RELPATH
  129. //
  130. // Parameters:
  131. // ----------
  132. // objectToGetInstancesOf IN : class whose instances to be retrieved.
  133. // relPath IN : instances __RELPATH
  134. // instanceStore OUT : vector containing instances.
  135. //
  136. // Returns:
  137. // -------
  138. // SUCCESS else errorcode
  139. MWmiObject_Error
  140. getSpecificInstance(
  141. const _bstr_t& objectToGetInstancesOf,
  142. const _bstr_t& relPath,
  143. vector< MWmiInstance >* instanceStore );
  144. //
  145. // Description:
  146. // -----------
  147. // gets instances of a particular class having specific __RELPATH
  148. //
  149. // Parameters:
  150. // ----------
  151. // objectToGetInstancesOf IN : class whose instances to be retrieved.
  152. // query IN : the query to be run.
  153. // instanceStore OUT : vector containing instances.
  154. //
  155. // Returns:
  156. // -------
  157. // SUCCESS else errorcode
  158. MWmiObject_Error
  159. getQueriedInstances(
  160. const _bstr_t& objectToGetInstancesOf,
  161. const _bstr_t& query,
  162. vector< MWmiInstance >* instanceStore );
  163. //
  164. // Description:
  165. // -----------
  166. // creates instance of a particular class.
  167. //
  168. // Parameters:
  169. // ----------
  170. // objectToCreateInstancesOf IN : class whose instances to be created
  171. // instanceParameters IN : parameters for the instance to be created.
  172. //
  173. // Returns:
  174. // -------
  175. // SUCCESS else error code.
  176. MWmiObject_Error
  177. createInstance(
  178. const _bstr_t& objectToCreateInstancesOf,
  179. vector<MWmiParameter *>& instanceParameters );
  180. // MWmiInstance* instanceCreated );
  181. //
  182. // Description:
  183. // -----------
  184. // deletes instance.
  185. //
  186. // Parameters:
  187. // ----------
  188. // instanceToDelete IN : instance to delete.
  189. //
  190. // Returns:
  191. // -------
  192. // SUCCESS else error code.
  193. MWmiObject_Error
  194. deleteInstance( MWmiInstance& instanceToDelete );
  195. //
  196. // Description:
  197. // -----------
  198. // gets status of object.
  199. //
  200. // Parameters:
  201. // ----------
  202. // none.
  203. //
  204. // Returns:
  205. // -------
  206. // SUCCESS else error code.
  207. MWmiObject_Error
  208. getStatus();
  209. private:
  210. enum
  211. {
  212. timesToRetry = 20,
  213. };
  214. IWbemLocatorPtr pwl;
  215. IWbemServicesPtr pws;
  216. _bstr_t _nameSpace;
  217. MWmiObject_Error status;
  218. MWmiObject_Error
  219. getPath( const _bstr_t& objectToRunMethodOn,
  220. vector<_bstr_t> *pathStore );
  221. MWmiObject_Error
  222. getSpecificPath( const _bstr_t& objectToRunMethodOn,
  223. const _bstr_t& relPath,
  224. vector<_bstr_t> *pathStore );
  225. MWmiObject_Error
  226. getQueriedPath( const _bstr_t& objectToRunMethodOn,
  227. const _bstr_t& query,
  228. vector<_bstr_t>* pathStore );
  229. HRESULT
  230. MWmiObject::betterConnectServer(
  231. const BSTR strNetworkResource,
  232. const BSTR strUser,
  233. const BSTR strPassword,
  234. const BSTR strLocale,
  235. LONG lSecurityFlags,
  236. const BSTR strAuthority,
  237. IWbemContext *pCtx,
  238. IWbemServices **ppNamespace
  239. );
  240. };
  241. //
  242. // Ensure type safety
  243. typedef class MWmiObject MWmiObject;
  244. #endif