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.

285 lines
10 KiB

  1. //***************************************************************************
  2. //
  3. // sample.h
  4. //
  5. // Module: WINMGMT class provider sample code
  6. //
  7. // Purpose: Genral purpose include file.
  8. //
  9. // Copyright (c) 2000 Microsoft Corporation
  10. //
  11. //***************************************************************************
  12. #ifndef _sample_H_
  13. #define _sample_H_
  14. #include <wbemprov.h>
  15. #include "testinfo.h"
  16. typedef LPVOID * PPVOID;
  17. // Provider interfaces are provided by objects of this class
  18. class CClassPro : public IWbemServices, public IWbemProviderInit
  19. {
  20. private:
  21. HRESULT LookupTestServices(
  22. const BSTR CdmClassName,
  23. CTestServices **TestServices
  24. );
  25. CTestServices *FindExistingTestServices(
  26. PWCHAR CdmClassName
  27. );
  28. HRESULT CreateTestInst(
  29. CTestServices *WdmTest,
  30. IWbemClassObject **pCdmTest,
  31. IWbemContext *pCtx
  32. );
  33. HRESULT CreateResultForMSEInst(
  34. CTestServices *WdmTest,
  35. IWbemClassObject **pCdmResultForMSE,
  36. int RelPathIndex,
  37. IWbemClassObject *pCdmResult,
  38. IWbemContext *pCtx
  39. );
  40. HRESULT CreateResultForTestInst(
  41. CTestServices *WdmTest,
  42. IWbemClassObject **pCdmResultForTest,
  43. IWbemClassObject *pCdmResult,
  44. IWbemContext *pCtx
  45. );
  46. HRESULT CreateTestForMSEInst(
  47. CTestServices *WdmTest,
  48. IWbemClassObject **pCdmTestForMSE,
  49. int RelPathIndex,
  50. IWbemContext *pCtx
  51. );
  52. HRESULT CreateSettingForTestInst(
  53. CTestServices *WdmTest,
  54. IWbemClassObject **pCdmSettingForTest,
  55. int RelPathIndex,
  56. ULONG SettingIndex,
  57. IWbemContext *pCtx
  58. );
  59. protected:
  60. ULONG m_cRef; //Object reference count
  61. IWbemServices * m_pCdmServices;
  62. public:
  63. CClassPro(BSTR ObjectPath = NULL, BSTR User = NULL, BSTR Password = NULL, IWbemContext * pCtx=NULL);
  64. ~CClassPro(void);
  65. //Non-delegating object IUnknown
  66. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  67. STDMETHODIMP_(ULONG) AddRef(void);
  68. STDMETHODIMP_(ULONG) Release(void);
  69. //IWbemProviderInit
  70. HRESULT STDMETHODCALLTYPE Initialize(
  71. /* [in] */ LPWSTR pszUser,
  72. /* [in] */ LONG lFlags,
  73. /* [in] */ LPWSTR pszNamespace,
  74. /* [in] */ LPWSTR pszLocale,
  75. /* [in] */ IWbemServices *pNamespace,
  76. /* [in] */ IWbemContext *pCtx,
  77. /* [in] */ IWbemProviderInitSink *pInitSink
  78. );
  79. SCODE GetByPath( BSTR Path, IWbemClassObject FAR* FAR* pObj, IWbemContext *pCtx);
  80. //IWbemServices
  81. HRESULT STDMETHODCALLTYPE OpenNamespace(
  82. /* [in] */ const BSTR Namespace,
  83. /* [in] */ long lFlags,
  84. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  85. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  86. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) {return WBEM_E_NOT_SUPPORTED;};
  87. HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  88. /* [in] */ IWbemObjectSink __RPC_FAR *pSink) {return WBEM_E_NOT_SUPPORTED;};
  89. HRESULT STDMETHODCALLTYPE QueryObjectSink(
  90. /* [in] */ long lFlags,
  91. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  92. HRESULT STDMETHODCALLTYPE GetObject(
  93. /* [in] */ const BSTR ObjectPath,
  94. /* [in] */ long lFlags,
  95. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  96. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  97. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  98. HRESULT STDMETHODCALLTYPE GetObjectAsync(
  99. /* [in] */ const BSTR ObjectPath,
  100. /* [in] */ long lFlags,
  101. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  102. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  103. HRESULT STDMETHODCALLTYPE PutClass(
  104. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  105. /* [in] */ long lFlags,
  106. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  107. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  108. HRESULT STDMETHODCALLTYPE PutClassAsync(
  109. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  110. /* [in] */ long lFlags,
  111. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  112. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  113. HRESULT STDMETHODCALLTYPE DeleteClass(
  114. /* [in] */ const BSTR Class,
  115. /* [in] */ long lFlags,
  116. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  117. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  118. HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  119. /* [in] */ const BSTR Class,
  120. /* [in] */ long lFlags,
  121. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  122. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  123. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  124. /* [in] */ const BSTR Superclass,
  125. /* [in] */ long lFlags,
  126. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  127. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  128. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  129. /* [in] */ const BSTR Superclass,
  130. /* [in] */ long lFlags,
  131. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  132. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  133. HRESULT STDMETHODCALLTYPE PutInstance(
  134. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  135. /* [in] */ long lFlags,
  136. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  137. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  138. HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  139. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  140. /* [in] */ long lFlags,
  141. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  142. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  143. HRESULT STDMETHODCALLTYPE DeleteInstance(
  144. /* [in] */ const BSTR ObjectPath,
  145. /* [in] */ long lFlags,
  146. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  147. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  148. HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  149. /* [in] */ const BSTR ObjectPath,
  150. /* [in] */ long lFlags,
  151. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  152. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  153. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  154. /* [in] */ const BSTR Class,
  155. /* [in] */ long lFlags,
  156. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  157. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  158. HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  159. /* [in] */ const BSTR Class,
  160. /* [in] */ long lFlags,
  161. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  162. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  163. HRESULT STDMETHODCALLTYPE ExecQuery(
  164. /* [in] */ const BSTR QueryLanguage,
  165. /* [in] */ const BSTR Query,
  166. /* [in] */ long lFlags,
  167. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  168. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  169. HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  170. /* [in] */ const BSTR QueryLanguage,
  171. /* [in] */ const BSTR Query,
  172. /* [in] */ long lFlags,
  173. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  174. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  175. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  176. /* [in] */ const BSTR QueryLanguage,
  177. /* [in] */ const BSTR Query,
  178. /* [in] */ long lFlags,
  179. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  180. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  181. HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  182. /* [in] */ const BSTR QueryLanguage,
  183. /* [in] */ const BSTR Query,
  184. /* [in] */ long lFlags,
  185. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  186. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  187. HRESULT STDMETHODCALLTYPE ExecMethod( const BSTR, const BSTR, long, IWbemContext*,
  188. IWbemClassObject*, IWbemClassObject**, IWbemCallResult**) {return WBEM_E_NOT_SUPPORTED; };
  189. HRESULT STDMETHODCALLTYPE ExecMethodAsync( const BSTR, const BSTR, long,
  190. IWbemContext*, IWbemClassObject*, IWbemObjectSink*);
  191. };
  192. typedef CClassPro *PCClassPro;
  193. // This class is the class factory for CClassPro objects.
  194. class CProvFactory : public IClassFactory
  195. {
  196. protected:
  197. ULONG m_cRef;
  198. public:
  199. CProvFactory(void);
  200. ~CProvFactory(void);
  201. //IUnknown members
  202. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  203. STDMETHODIMP_(ULONG) AddRef(void);
  204. STDMETHODIMP_(ULONG) Release(void);
  205. //IClassFactory members
  206. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID
  207. , PPVOID);
  208. STDMETHODIMP LockServer(BOOL);
  209. };
  210. typedef CProvFactory *PCProvFactory;
  211. // These variables keep track of when the module can be unloaded
  212. extern LONG g_cObj;
  213. extern LONG g_cLock;
  214. // General purpose utilities.
  215. SCODE CreateInst(
  216. IWbemServices * pNamespace,
  217. IWbemClassObject ** pNewInst,
  218. WCHAR * pwcClassName,
  219. IWbemContext *pCtx
  220. );
  221. #endif