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.

436 lines
13 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // services.h
  6. //
  7. // alanbos 27-Mar-00 Created.
  8. //
  9. // CSWbemServices definition.
  10. //
  11. //***************************************************************************
  12. #ifndef _SERVICES_H_
  13. #define _SERVICES_H_
  14. //***************************************************************************
  15. //
  16. // CLASS NAME:
  17. //
  18. // CSWbemServices
  19. //
  20. // DESCRIPTION:
  21. //
  22. // Implements the IWbemSServices interface.
  23. //
  24. //***************************************************************************
  25. class CSWbemServices : public ISWbemServicesEx,
  26. public IDispatchEx,
  27. public ISupportErrorInfo,
  28. public ISWbemInternalServices,
  29. public IProvideClassInfo
  30. {
  31. private:
  32. CComBSTR m_bsNamespacePath;
  33. BSTR m_bsLocale;
  34. CDispatchHelp m_Dispatch;
  35. CSWbemSecurity* m_SecurityInfo;
  36. IServiceProvider *m_pIServiceProvider;
  37. IUnsecuredApartment *m_pUnsecuredApartment;
  38. static BSTR BuildPath (BSTR bsClassName, VARIANT *pKeyValue);
  39. static BSTR BuildPath (BSTR bsClassName,
  40. /*ISWbemNamedValueSet*/ IDispatch *pCompoundKeys);
  41. protected:
  42. long m_cRef; //Object reference count
  43. public:
  44. CSWbemServices (IWbemServices *pIWbemServices,
  45. BSTR bsNamespacePath,
  46. BSTR bsAuthority, BSTR bsUser, BSTR bsPassword,
  47. CWbemLocatorSecurity *pSecurity = NULL,
  48. BSTR bsLocale = NULL);
  49. CSWbemServices (IWbemServices *pIWbemServices,
  50. BSTR bsNamespacePath,
  51. COAUTHIDENTITY *pCoAuthIdentity,
  52. BSTR bsPrincipal,
  53. BSTR bsAuthority);
  54. CSWbemServices (CSWbemServices *pService, CSWbemSecurity *pSecurity);
  55. CSWbemServices (ISWbemInternalServices *pService);
  56. CSWbemServices (IWbemServices *pIWbemServices, CSWbemServices *pServiceb);
  57. IUnsecuredApartment *GetCachedUnsecuredApartment();
  58. ~CSWbemServices(void);
  59. //Non-delegating object IUnknown
  60. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  61. STDMETHODIMP_(ULONG) AddRef(void);
  62. STDMETHODIMP_(ULONG) Release(void);
  63. // IDispatch methods should be inline
  64. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
  65. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
  66. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  67. UINT cNames, LCID lcid, DISPID* rgdispid);
  68. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  69. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  70. EXCEPINFO* pexcepinfo, UINT* puArgErr);
  71. // IDispatchEx methods should be inline
  72. HRESULT STDMETHODCALLTYPE GetDispID(
  73. /* [in] */ BSTR bstrName,
  74. /* [in] */ DWORD grfdex,
  75. /* [out] */ DISPID __RPC_FAR *pid);
  76. /* [local] */ HRESULT STDMETHODCALLTYPE InvokeEx(
  77. /* [in] */ DISPID id,
  78. /* [in] */ LCID lcid,
  79. /* [in] */ WORD wFlags,
  80. /* [in] */ DISPPARAMS __RPC_FAR *pdp,
  81. /* [out] */ VARIANT __RPC_FAR *pvarRes,
  82. /* [out] */ EXCEPINFO __RPC_FAR *pei,
  83. /* [unique][in] */ IServiceProvider __RPC_FAR *pspCaller);
  84. HRESULT STDMETHODCALLTYPE DeleteMemberByName(
  85. /* [in] */ BSTR bstr,
  86. /* [in] */ DWORD grfdex);
  87. HRESULT STDMETHODCALLTYPE DeleteMemberByDispID(
  88. /* [in] */ DISPID id);
  89. HRESULT STDMETHODCALLTYPE GetMemberProperties(
  90. /* [in] */ DISPID id,
  91. /* [in] */ DWORD grfdexFetch,
  92. /* [out] */ DWORD __RPC_FAR *pgrfdex);
  93. HRESULT STDMETHODCALLTYPE GetMemberName(
  94. /* [in] */ DISPID id,
  95. /* [out] */ BSTR __RPC_FAR *pbstrName);
  96. HRESULT STDMETHODCALLTYPE GetNextDispID(
  97. /* [in] */ DWORD grfdex,
  98. /* [in] */ DISPID id,
  99. /* [out] */ DISPID __RPC_FAR *pid);
  100. HRESULT STDMETHODCALLTYPE GetNameSpaceParent(
  101. /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppunk);
  102. // ISWbemInternalServices methods
  103. STDMETHODIMP GetIWbemServices (IWbemServices **ppService);
  104. STDMETHODIMP GetNamespacePath (BSTR *bsNamespacePath)
  105. {
  106. HRESULT hr = WBEM_E_FAILED;
  107. if (bsNamespacePath)
  108. hr = m_bsNamespacePath.CopyTo (bsNamespacePath);
  109. return hr;
  110. }
  111. STDMETHODIMP GetLocale (BSTR *bsLocale)
  112. {
  113. HRESULT hr = WBEM_E_FAILED;
  114. if (bsLocale)
  115. {
  116. *bsLocale = SysAllocString (GetLocale ());
  117. hr = S_OK;
  118. }
  119. return hr;
  120. }
  121. STDMETHODIMP GetISWbemInternalSecurity (ISWbemInternalSecurity **ppISWbemInternalSecurity)
  122. {
  123. HRESULT hr = WBEM_E_FAILED;
  124. if (ppISWbemInternalSecurity && m_SecurityInfo)
  125. {
  126. m_SecurityInfo->QueryInterface (IID_ISWbemInternalSecurity, (void**) ppISWbemInternalSecurity);
  127. hr = S_OK;
  128. }
  129. return hr;
  130. }
  131. // ISWbemServices methods
  132. HRESULT STDMETHODCALLTYPE Get
  133. (
  134. /*[in]*/ BSTR objectPath,
  135. /*[in]*/ long lFlags,
  136. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  137. /*[out]*/ ISWbemObject **ppObject
  138. );
  139. HRESULT STDMETHODCALLTYPE Delete
  140. (
  141. /*[in]*/ BSTR objectPath,
  142. /*[in]*/ long lFlags,
  143. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext
  144. );
  145. HRESULT STDMETHODCALLTYPE InstancesOf
  146. (
  147. /*[in]*/ BSTR className,
  148. /*[in]*/ long lFlags,
  149. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  150. /*[out]*/ ISWbemObjectSet **ppEnum
  151. );
  152. HRESULT STDMETHODCALLTYPE ExecQuery
  153. (
  154. /*[in]*/ BSTR Query,
  155. /*[in]*/ BSTR QueryLanguage,
  156. /*[in]*/ long lFlags,
  157. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  158. /*[out]*/ ISWbemObjectSet **ppEnum
  159. );
  160. HRESULT STDMETHODCALLTYPE ExecNotificationQuery
  161. (
  162. /*[in]*/ BSTR Query,
  163. /*[in]*/ BSTR QueryLanguage,
  164. /*[in]*/ long lFlags,
  165. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  166. /*[out]*/ ISWbemEventSource **ppEnum
  167. );
  168. HRESULT STDMETHODCALLTYPE AssociatorsOf
  169. (
  170. /*[in]*/ BSTR objectPath,
  171. /*[in]*/ BSTR assocClass,
  172. /*[in]*/ BSTR resultClass,
  173. /*[in]*/ BSTR resultRole,
  174. /*[in]*/ BSTR role,
  175. /*[in]*/ VARIANT_BOOL classesOnly,
  176. /*[in]*/ VARIANT_BOOL schemaOnly,
  177. /*[in]*/ BSTR requiredAssocQualifier,
  178. /*[in]*/ BSTR requiredQualifier,
  179. /*[in]*/ long lFlags,
  180. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  181. /*[out]*/ ISWbemObjectSet **ppEnum
  182. );
  183. HRESULT STDMETHODCALLTYPE ReferencesTo
  184. (
  185. /*[in]*/ BSTR objectPath,
  186. /*[in]*/ BSTR resultClass,
  187. /*[in]*/ BSTR role,
  188. /*[in]*/ VARIANT_BOOL classesOnly,
  189. /*[in]*/ VARIANT_BOOL schemaOnly,
  190. /*[in]*/ BSTR requiredQualifier,
  191. /*[in]*/ long lFlags,
  192. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  193. /*[out]*/ ISWbemObjectSet **ppEnum
  194. );
  195. HRESULT STDMETHODCALLTYPE ExecMethod
  196. (
  197. /*[in]*/ BSTR className,
  198. /*[in]*/ BSTR methodName,
  199. /*[in]*/ /*ISWbemObject*/ IDispatch *pInParams,
  200. /*[in]*/ long lFlags,
  201. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  202. /*[out]*/ ISWbemObject **ppOutParams
  203. );
  204. HRESULT STDMETHODCALLTYPE SubclassesOf
  205. (
  206. /*[in]*/ BSTR superclass,
  207. /*[in]*/ long lFlags,
  208. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  209. /*[out]*/ ISWbemObjectSet **ppEnum
  210. );
  211. HRESULT STDMETHODCALLTYPE GetAsync
  212. (
  213. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  214. /* [defaultvalue][optional][in] */ BSTR strObjectPath,
  215. /* [defaultvalue][optional][in] */ long iFlags,
  216. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  217. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  218. );
  219. HRESULT STDMETHODCALLTYPE DeleteAsync
  220. (
  221. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  222. /* [in] */ BSTR strObjectPath,
  223. /* [defaultvalue][optional][in] */ long iFlags,
  224. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  225. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  226. );
  227. HRESULT STDMETHODCALLTYPE InstancesOfAsync
  228. (
  229. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  230. /* [in] */ BSTR strClass,
  231. /* [defaultvalue][optional][in] */ long iFlags,
  232. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  233. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  234. );
  235. HRESULT STDMETHODCALLTYPE SubclassesOfAsync
  236. (
  237. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  238. /* [defaultvalue][optional][in] */ BSTR strSuperclass,
  239. /* [defaultvalue][optional][in] */ long iFlags,
  240. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  241. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  242. );
  243. HRESULT STDMETHODCALLTYPE ExecQueryAsync
  244. (
  245. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  246. /* [in] */ BSTR Query,
  247. /* [defaultvalue][optional][in] */ BSTR QueryLanguage,
  248. /* [defaultvalue][optional][in] */ long lFlags,
  249. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pContext,
  250. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  251. );
  252. HRESULT STDMETHODCALLTYPE AssociatorsOfAsync
  253. (
  254. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  255. /* [in] */ BSTR strObjectPath,
  256. /* [defaultvalue][optional][in] */ BSTR strAssocClass,
  257. /* [defaultvalue][optional][in] */ BSTR strResultClass,
  258. /* [defaultvalue][optional][in] */ BSTR strResultRole,
  259. /* [defaultvalue][optional][in] */ BSTR strRole,
  260. /* [defaultvalue][optional][in] */ VARIANT_BOOL bClassesOnly,
  261. /* [defaultvalue][optional][in] */ VARIANT_BOOL bSchemaOnly,
  262. /* [defaultvalue][optional][in] */ BSTR strRequiredAssocQualifier,
  263. /* [defaultvalue][optional][in] */ BSTR strRequiredQualifier,
  264. /* [defaultvalue][optional][in] */ long iFlags,
  265. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  266. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  267. );
  268. HRESULT STDMETHODCALLTYPE ReferencesToAsync
  269. (
  270. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  271. /* [in] */ BSTR objectPath,
  272. /* [defaultvalue][optional][in] */ BSTR strResultClass,
  273. /* [defaultvalue][optional][in] */ BSTR strRole,
  274. /* [defaultvalue][optional][in] */ VARIANT_BOOL bClassesOnly,
  275. /* [defaultvalue][optional][in] */ VARIANT_BOOL bSchemaOnly,
  276. /* [defaultvalue][optional][in] */ BSTR strRequiredQualifier,
  277. /* [defaultvalue][optional][in] */ long iFlags,
  278. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  279. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  280. );
  281. HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync
  282. (
  283. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  284. /* [in] */ BSTR Query,
  285. /* [defaultvalue][optional][in] */ BSTR strQueryLanguage,
  286. /* [defaultvalue][optional][in] */ long iFlags,
  287. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  288. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  289. );
  290. HRESULT STDMETHODCALLTYPE ExecMethodAsync
  291. (
  292. /* [in] */ IDispatch __RPC_FAR *pAsyncNotify,
  293. /* [in] */ BSTR strObjectPath,
  294. /* [in] */ BSTR strMethodName,
  295. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objInParams,
  296. /* [defaultvalue][optional][in] */ long iFlags,
  297. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *objContext,
  298. /* [defaultvalue][optional][in] */ IDispatch __RPC_FAR *pAsyncContext
  299. );
  300. HRESULT STDMETHODCALLTYPE get_Security_
  301. (
  302. /* [in] */ ISWbemSecurity **ppSecurity
  303. );
  304. // ISWbemServicesEx methods
  305. HRESULT STDMETHODCALLTYPE Put(
  306. /* [in] */ ISWbemObjectEx *objWbemObject,
  307. /* [in] */ long iFlags,
  308. /* [in] */ /*ISWbemNamedValueSet*/ IDispatch *objWbemNamedValueSet,
  309. /* [out, retval] */ ISWbemObjectPath **objWbemObjectPath
  310. );
  311. HRESULT STDMETHODCALLTYPE PutAsync(
  312. /* [in] */ ISWbemSink *objWbemSink,
  313. /* [in] */ ISWbemObjectEx *objWbemObject,
  314. /* [in] */ long iFlags,
  315. /* [in] */ /*ISWbemNamedValueSet*/ IDispatch *objWbemNamedValueSet,
  316. /* [in] */ /*ISWbemNamedValueSet*/ IDispatch *objWbemAsyncContext
  317. );
  318. // ISupportErrorInfo methods
  319. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  320. (
  321. /* [in] */ REFIID riid
  322. );
  323. // IProvideClassInfo methods
  324. HRESULT STDMETHODCALLTYPE GetClassInfo
  325. (
  326. /* [in,out] */ ITypeInfo **ppTI
  327. )
  328. {
  329. return m_Dispatch.GetClassInfo (ppTI);
  330. };
  331. // Other methods
  332. CSWbemSecurity *GetSecurityInfo ()
  333. {
  334. CSWbemSecurity *pInfo = NULL;
  335. if (m_SecurityInfo)
  336. {
  337. pInfo = m_SecurityInfo;
  338. pInfo->AddRef ();
  339. }
  340. return pInfo;
  341. }
  342. BSTR GetLocale ()
  343. {
  344. return m_bsLocale;
  345. }
  346. const CComBSTR & GetPath ()
  347. {
  348. return m_bsNamespacePath;
  349. }
  350. HRESULT CancelAsyncCall(IWbemObjectSink *sink);
  351. IWbemServices *GetIWbemServices ()
  352. {
  353. IWbemServices *pService = NULL;
  354. if (m_SecurityInfo)
  355. pService = (IWbemServices *) m_SecurityInfo->GetProxy ();
  356. return pService;
  357. }
  358. static IWbemServices *GetIWbemServices (IDispatch *pDispatch);
  359. };
  360. #endif