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.

314 lines
7.0 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ObjectPath.h
  7. //
  8. // Implementation File:
  9. // ObjectPath.cpp
  10. //
  11. // Description:
  12. // Definition of the CObjpath class.
  13. //
  14. // Author:
  15. // Henry Wang (HenryWa) 24-AUG-1999
  16. //
  17. // Notes:
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #pragma once
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Include Files
  23. //////////////////////////////////////////////////////////////////////////////
  24. #include "genlex.h" //wbem sdk header
  25. #include "objpath.h" //wbem sdk header
  26. //////////////////////////////////////////////////////////////////////////////
  27. // Forward Declarations
  28. //////////////////////////////////////////////////////////////////////////////
  29. class CObjPath;
  30. class CProvException;
  31. class CWbemClassObject;
  32. /////////////////////////////////////////////////////////////////////////////
  33. //++
  34. //
  35. // class CObjPath
  36. //
  37. // Description:
  38. // CObjpath class make it easier to work with Object path string
  39. //
  40. //--
  41. /////////////////////////////////////////////////////////////////////////////
  42. class CObjPath
  43. {
  44. //
  45. // constructor and desctructor
  46. //
  47. public:
  48. CObjPath( void );
  49. virtual ~CObjPath( void );
  50. public:
  51. _bstr_t GetObjectPathString( void );
  52. BOOL AddProperty(
  53. LPCWSTR pwszNameIn,
  54. LPCWSTR pwszValueIn
  55. );
  56. BOOL AddProperty(
  57. LPCWSTR pwszNameIn,
  58. VARIANT * pvValueIn
  59. );
  60. BOOL SetClass(
  61. IN LPCWSTR pwszValue
  62. );
  63. _bstr_t GetStringValueForProperty(
  64. LPCWSTR pwszIn
  65. );
  66. _bstr_t GetClassName( void );
  67. BOOL Init(
  68. LPCWSTR pwszPathIn
  69. );
  70. protected:
  71. ParsedObjectPath * m_parsedObj;
  72. }; //*** class CObjPath
  73. /////////////////////////////////////////////////////////////////////////////
  74. //++
  75. //
  76. // class CProvException
  77. //
  78. // Description:
  79. // Base exception class, declares common interface and member data
  80. // for all exception subclass
  81. //
  82. //--
  83. /////////////////////////////////////////////////////////////////////////////
  84. class CProvException
  85. {
  86. public:
  87. CProvException(
  88. HRESULT hrIn
  89. )
  90. : m_hr( hrIn )
  91. {
  92. }
  93. CProvException(
  94. DWORD nWin32ErrorIn
  95. )
  96. : m_hr( 0 )
  97. {
  98. m_hr = HRESULT_FROM_WIN32( nWin32ErrorIn );
  99. }
  100. virtual ~CProvException( void )
  101. {
  102. }
  103. CProvException(
  104. const CProvException & rhsIn
  105. )
  106. : m_hr( 0 )
  107. {
  108. m_bstrError = rhsIn.m_bstrError;
  109. m_hr = rhsIn.m_hr;
  110. }
  111. CProvException & operator=(
  112. const CProvException & rhsIn
  113. )
  114. {
  115. m_bstrError = rhsIn.m_bstrError;
  116. m_hr = rhsIn.m_hr;
  117. return *this;
  118. }
  119. LPCWSTR PwszErrorMessage( void ) const;
  120. BOOL BIsWmiError( void ) const
  121. {
  122. return HRESULT_FACILITY( m_hr ) == 4;
  123. }
  124. DWORD DwGetError( void ) const throw()
  125. {
  126. return HRESULT_CODE( m_hr );
  127. }
  128. HRESULT hrGetError( void ) const throw()
  129. {
  130. return m_hr;
  131. }
  132. protected:
  133. mutable _bstr_t m_bstrError;
  134. HRESULT m_hr;
  135. }; //*** class CProvException
  136. /////////////////////////////////////////////////////////////////////////////
  137. //++
  138. //
  139. // class CWbemClassObject
  140. //
  141. // Description:
  142. // Wrap for IWbemClassObject
  143. //
  144. //--
  145. /////////////////////////////////////////////////////////////////////////////
  146. class CWbemClassObject
  147. {
  148. protected:
  149. IWbemClassObject * m_pClassObject;
  150. VARIANT m_v;
  151. public:
  152. CWbemClassObject( void );
  153. CWbemClassObject( IWbemClassObject * pInstIn );
  154. virtual ~CWbemClassObject( void );
  155. IWbemClassObject ** operator&( void )
  156. {
  157. return &m_pClassObject;
  158. }
  159. CWbemClassObject & operator=( IWbemClassObject * pInstIn )
  160. {
  161. if( pInstIn != NULL )
  162. {
  163. pInstIn->AddRef();
  164. if ( m_pClassObject != NULL )
  165. {
  166. m_pClassObject->Release();
  167. }
  168. m_pClassObject = pInstIn;
  169. }
  170. return *this;
  171. }
  172. CWbemClassObject & operator=( CWbemClassObject & rInstIn )
  173. {
  174. if ( m_pClassObject != NULL )
  175. {
  176. m_pClassObject->Release();
  177. }
  178. m_pClassObject = rInstIn.m_pClassObject;
  179. if ( m_pClassObject != NULL )
  180. {
  181. m_pClassObject->AddRef();
  182. }
  183. return *this;
  184. }
  185. SCODE SetProperty(
  186. LPCSTR pszValueIn,
  187. LPCWSTR pwszPropNameIn
  188. );
  189. SCODE SetProperty(
  190. DWORD dwValueIn,
  191. LPCWSTR pwszPropNameIn
  192. );
  193. SCODE SetProperty(
  194. LPCWSTR pwszValueIn,
  195. LPCWSTR pwszPropNameIn
  196. );
  197. SCODE SetProperty(
  198. IWbemClassObject * pWbemClassObjectIn,
  199. LPCWSTR pwszPropNameIn
  200. );
  201. SCODE SetProperty(
  202. DWORD dwSizeIn,
  203. PBYTE pByteIn,
  204. LPCWSTR pwszPropNameIn
  205. );
  206. SCODE SetProperty(
  207. DWORD dwSizeIn,
  208. LPCWSTR pwszMultiSzIn,
  209. LPCWSTR pwszPropNameIn
  210. );
  211. SCODE SetProperty(
  212. DWORD dwSizeIn,
  213. BSTR * pbstrIn,
  214. LPCWSTR pwszPropNameIn
  215. );
  216. SCODE GetProperty(
  217. DWORD * pdwValueOut,
  218. LPCWSTR pwszPropNameIn
  219. );
  220. SCODE GetProperty(
  221. DWORD * pdwSizeOut,
  222. PBYTE * ppByteOut,
  223. LPCWSTR pwszPropNameIn
  224. );
  225. SCODE GetProperty(
  226. DWORD * pdwSizeOut,
  227. _bstr_t ** ppbstrOut,
  228. LPCWSTR pwszPropNameIn
  229. );
  230. SCODE GetPropertyMultiSz(
  231. DWORD * pdwSizeOut,
  232. LPWSTR * ppwszMultiSzOut,
  233. LPCWSTR pwszPropNameIn
  234. );
  235. SCODE GetProperty(
  236. _bstr_t & rBstrOut,
  237. LPCWSTR pwszPropNameIn
  238. );
  239. SCODE GetProperty(
  240. BOOL * pfValueOut,
  241. LPCWSTR pwszPropNameIn
  242. );
  243. SCODE GetProperty(
  244. VARIANT * pVariantOut,
  245. LPCWSTR pwszPropNameIn
  246. );
  247. SCODE GetProperty(
  248. CWbemClassObject & rWcoInout,
  249. LPCWSTR pwszPropNameIn
  250. );
  251. SCODE GetMethod(
  252. BSTR bstrMethodNameIn,
  253. LONG lFlagIn,
  254. IWbemClassObject ** ppINOut,
  255. IWbemClassObject ** ppOUTOut
  256. );
  257. SCODE SpawnInstance(
  258. LONG lFlagIn,
  259. IWbemClassObject ** ppNewOut
  260. );
  261. SCODE SpawnDerivedClass(
  262. LONG lFlagIn,
  263. IWbemClassObject ** ppNewOut
  264. );
  265. IWbemClassObject * data( void )
  266. {
  267. return m_pClassObject;
  268. }
  269. }; //*** class CWbemClassObject