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.

367 lines
8.2 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. // MSP Prabu (mprabu) 06-Jan-2001
  17. //
  18. // Notes:
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #pragma once
  22. //////////////////////////////////////////////////////////////////////////////
  23. // Include Files
  24. //////////////////////////////////////////////////////////////////////////////
  25. #include <genlex.h> //wbem sdk header
  26. #include <objpath.h> //wbem sdk header
  27. //////////////////////////////////////////////////////////////////////////////
  28. // Forward Declarations
  29. //////////////////////////////////////////////////////////////////////////////
  30. class CObjPath;
  31. class CProvException;
  32. class CWbemClassObject;
  33. /////////////////////////////////////////////////////////////////////////////
  34. //++
  35. //
  36. // class CObjPath
  37. //
  38. // Description:
  39. // CObjpath class make it easier to work with Object path string
  40. //
  41. //--
  42. /////////////////////////////////////////////////////////////////////////////
  43. class CObjPath
  44. {
  45. //
  46. // constructor and desctructor
  47. //
  48. public:
  49. CObjPath( void );
  50. virtual ~CObjPath( void );
  51. public:
  52. _bstr_t GetObjectPathString( void );
  53. BOOL AddProperty(
  54. LPCWSTR pwszNameIn,
  55. LPCWSTR pwszValueIn
  56. );
  57. BOOL AddProperty(
  58. LPCWSTR pwszNameIn,
  59. VARIANT * pvValueIn
  60. );
  61. BOOL SetClass(
  62. IN LPCWSTR pwszValue
  63. );
  64. _bstr_t GetStringValueForProperty(
  65. LPCWSTR pwszIn
  66. );
  67. long GetLongValueForProperty(
  68. LPCWSTR pwszIn
  69. );
  70. LONGLONG GetI64ValueForProperty(
  71. LPCWSTR pwszIn
  72. );
  73. _bstr_t GetClassName( void );
  74. BOOL Init(
  75. LPCWSTR pwszPathIn
  76. );
  77. protected:
  78. ParsedObjectPath * m_parsedObj;
  79. }; //*** class CObjPath
  80. /////////////////////////////////////////////////////////////////////////////
  81. //++
  82. //
  83. // class CProvException
  84. //
  85. // Description:
  86. // Base exception class, declares common interface and member data
  87. // for all exception subclass
  88. //
  89. //--
  90. /////////////////////////////////////////////////////////////////////////////
  91. class CProvException
  92. {
  93. public:
  94. CProvException(
  95. HRESULT hrIn
  96. )
  97. : m_hr( hrIn )
  98. {
  99. }
  100. CProvException(
  101. DWORD nWin32ErrorIn
  102. )
  103. : m_hr( 0 )
  104. {
  105. m_hr = HRESULT_FROM_WIN32( nWin32ErrorIn );
  106. }
  107. virtual ~CProvException( void )
  108. {
  109. }
  110. CProvException(
  111. const CProvException & rhsIn
  112. )
  113. : m_hr( 0 )
  114. {
  115. m_bstrError = rhsIn.m_bstrError;
  116. m_bstrErrorHelp = rhsIn.m_bstrErrorHelp;
  117. m_hr = rhsIn.m_hr;
  118. }
  119. CProvException & operator=(
  120. const CProvException & rhsIn
  121. )
  122. {
  123. m_bstrError = rhsIn.m_bstrError;
  124. m_bstrErrorHelp = rhsIn.m_bstrErrorHelp;
  125. m_hr = rhsIn.m_hr;
  126. return *this;
  127. }
  128. LPCWSTR PwszErrorMessage( void ) const;
  129. BOOL BIsWmiError( void ) const
  130. {
  131. return HRESULT_FACILITY( m_hr ) == 4;
  132. }
  133. DWORD DwGetError( void ) const throw()
  134. {
  135. return HRESULT_CODE( m_hr );
  136. }
  137. HRESULT hrGetError( void ) const throw()
  138. {
  139. return m_hr;
  140. }
  141. void SetErrorHelpInfo( LPCWSTR pwsz )
  142. {
  143. m_bstrErrorHelp = pwsz;
  144. }
  145. LPCWSTR PwszGetErrorHelpInfo( void )
  146. {
  147. return m_bstrErrorHelp;
  148. }
  149. protected:
  150. mutable _bstr_t m_bstrError;
  151. mutable _bstr_t m_bstrErrorHelp;
  152. HRESULT m_hr;
  153. }; //*** class CProvException
  154. /////////////////////////////////////////////////////////////////////////////
  155. //++
  156. //
  157. // class CWbemClassObject
  158. //
  159. // Description:
  160. // Wrap for IWbemClassObject
  161. //
  162. //--
  163. /////////////////////////////////////////////////////////////////////////////
  164. class CWbemClassObject
  165. {
  166. protected:
  167. IWbemClassObject * m_pClassObject;
  168. VARIANT m_v;
  169. public:
  170. CWbemClassObject( void );
  171. CWbemClassObject( IWbemClassObject * pInstIn );
  172. virtual ~CWbemClassObject( void );
  173. IWbemClassObject ** operator&( void )
  174. {
  175. return &m_pClassObject;
  176. }
  177. CWbemClassObject & operator=( IWbemClassObject * pInstIn )
  178. {
  179. if( pInstIn != NULL )
  180. {
  181. pInstIn->AddRef();
  182. if ( m_pClassObject != NULL )
  183. {
  184. m_pClassObject->Release();
  185. }
  186. m_pClassObject = pInstIn;
  187. }
  188. return *this;
  189. }
  190. CWbemClassObject & operator=( CWbemClassObject & rInstIn )
  191. {
  192. if ( m_pClassObject != NULL )
  193. {
  194. m_pClassObject->Release();
  195. }
  196. m_pClassObject = rInstIn.m_pClassObject;
  197. if ( m_pClassObject != NULL )
  198. {
  199. m_pClassObject->AddRef();
  200. }
  201. return *this;
  202. }
  203. HRESULT SetProperty(
  204. LPCSTR pszValueIn,
  205. LPCWSTR pwszPropNameIn
  206. );
  207. HRESULT SetProperty(
  208. DWORD dwValueIn,
  209. LPCWSTR pwszPropNameIn
  210. );
  211. HRESULT SetPropertyR64(
  212. double dblValueIn,
  213. LPCWSTR pwszPropNameIn
  214. );
  215. HRESULT SetPropertyI64(
  216. LONGLONG llValueIn,
  217. LPCWSTR pwszPropNameIn
  218. );
  219. HRESULT SetPropertyI64(
  220. ULONGLONG llValueIn,
  221. LPCWSTR pwszPropNameIn
  222. );
  223. HRESULT SetProperty(
  224. LPCWSTR pwszValueIn,
  225. LPCWSTR pwszPropNameIn
  226. );
  227. HRESULT SetProperty(
  228. IWbemClassObject * pWbemClassObjectIn,
  229. LPCWSTR pwszPropNameIn
  230. );
  231. HRESULT SetProperty(
  232. DWORD dwSizeIn,
  233. PBYTE pByteIn,
  234. LPCWSTR pwszPropNameIn
  235. );
  236. HRESULT SetProperty(
  237. DWORD dwSizeIn,
  238. LPCWSTR pwszMultiSzIn,
  239. LPCWSTR pwszPropNameIn
  240. );
  241. HRESULT SetProperty(
  242. DWORD dwSizeIn,
  243. BSTR * pbstrIn,
  244. LPCWSTR pwszPropNameIn
  245. );
  246. HRESULT GetProperty(
  247. DWORD * pdwValueOut,
  248. LPCWSTR pwszPropNameIn
  249. );
  250. HRESULT GetPropertyR64(
  251. double * pdblValueOut,
  252. LPCWSTR pwszPropNameIn
  253. );
  254. HRESULT GetPropertyI64(
  255. LONGLONG * pllValueOut,
  256. LPCWSTR pwszPropNameIn
  257. );
  258. HRESULT GetProperty(
  259. DWORD * pdwSizeOut,
  260. PBYTE * ppByteOut,
  261. LPCWSTR pwszPropNameIn
  262. );
  263. HRESULT GetProperty(
  264. DWORD * pdwSizeOut,
  265. _bstr_t ** ppbstrOut,
  266. LPCWSTR pwszPropNameIn
  267. );
  268. HRESULT GetPropertyMultiSz(
  269. DWORD * pdwSizeOut,
  270. LPWSTR * ppwszMultiSzOut,
  271. LPCWSTR pwszPropNameIn
  272. );
  273. HRESULT GetProperty(
  274. _bstr_t & rBstrOut,
  275. LPCWSTR pwszPropNameIn
  276. );
  277. HRESULT GetProperty(
  278. BOOL * pfValueOut,
  279. LPCWSTR pwszPropNameIn
  280. );
  281. HRESULT GetProperty(
  282. VARIANT * pVariantOut,
  283. LPCWSTR pwszPropNameIn
  284. );
  285. HRESULT GetProperty(
  286. CWbemClassObject & rWcoInout,
  287. LPCWSTR pwszPropNameIn
  288. );
  289. HRESULT GetMethod(
  290. BSTR bstrMethodNameIn,
  291. LONG lFlagIn,
  292. IWbemClassObject ** ppINOut,
  293. IWbemClassObject ** ppOUTOut
  294. );
  295. HRESULT SpawnInstance(
  296. LONG lFlagIn,
  297. IWbemClassObject ** ppNewOut
  298. );
  299. HRESULT SpawnDerivedClass(
  300. LONG lFlagIn,
  301. IWbemClassObject ** ppNewOut
  302. );
  303. BOOL IsPropertyNull(
  304. LPCWSTR pwszPropNameIn
  305. );
  306. IWbemClassObject * data( void )
  307. {
  308. return m_pClassObject;
  309. }
  310. IWbemClassObject ** dataPtr( void )
  311. {
  312. return & m_pClassObject;
  313. }
  314. }; //*** class CWbemClassObject