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.

234 lines
9.2 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. typedef LPVOID * PPVOID;
  15. // Provider interfaces are provided by objects of this class
  16. class CClassPro : public IWbemServices, public IWbemProviderInit
  17. {
  18. private:
  19. HRESULT LookupWdmClass( IWbemContext *pCtx,
  20. const BSTR CimClassName,
  21. CWdmClass **WdmClassPtr
  22. );
  23. CWdmClass *FindExistingWdmClass(
  24. PWCHAR CimClassName
  25. );
  26. protected:
  27. ULONG m_cRef; //Object reference count
  28. IWbemServices * m_pCimServices;
  29. public:
  30. CClassPro(BSTR ObjectPath = NULL, BSTR User = NULL, BSTR Password = NULL, IWbemContext * pCtx=NULL);
  31. ~CClassPro(void);
  32. //Non-delegating object IUnknown
  33. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  34. STDMETHODIMP_(ULONG) AddRef(void);
  35. STDMETHODIMP_(ULONG) Release(void);
  36. //IWbemProviderInit
  37. HRESULT STDMETHODCALLTYPE Initialize(
  38. /* [in] */ LPWSTR pszUser,
  39. /* [in] */ LONG lFlags,
  40. /* [in] */ LPWSTR pszNamespace,
  41. /* [in] */ LPWSTR pszLocale,
  42. /* [in] */ IWbemServices *pNamespace,
  43. /* [in] */ IWbemContext *pCtx,
  44. /* [in] */ IWbemProviderInitSink *pInitSink
  45. );
  46. SCODE GetByPath(IWbemContext *pCtx, BSTR Path, IWbemClassObject FAR* FAR* pObj);
  47. //IWbemServices
  48. HRESULT STDMETHODCALLTYPE OpenNamespace(
  49. /* [in] */ const BSTR Namespace,
  50. /* [in] */ long lFlags,
  51. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  52. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  53. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) {return WBEM_E_NOT_SUPPORTED;};
  54. HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  55. /* [in] */ IWbemObjectSink __RPC_FAR *pSink) {return WBEM_E_NOT_SUPPORTED;};
  56. HRESULT STDMETHODCALLTYPE QueryObjectSink(
  57. /* [in] */ long lFlags,
  58. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  59. HRESULT STDMETHODCALLTYPE GetObject(
  60. /* [in] */ const BSTR ObjectPath,
  61. /* [in] */ long lFlags,
  62. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  63. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  64. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  65. HRESULT STDMETHODCALLTYPE GetObjectAsync(
  66. /* [in] */ const BSTR ObjectPath,
  67. /* [in] */ long lFlags,
  68. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  69. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  70. HRESULT STDMETHODCALLTYPE PutClass(
  71. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  72. /* [in] */ long lFlags,
  73. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  74. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  75. HRESULT STDMETHODCALLTYPE PutClassAsync(
  76. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  77. /* [in] */ long lFlags,
  78. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  79. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  80. HRESULT STDMETHODCALLTYPE DeleteClass(
  81. /* [in] */ const BSTR Class,
  82. /* [in] */ long lFlags,
  83. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  84. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  85. HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  86. /* [in] */ const BSTR Class,
  87. /* [in] */ long lFlags,
  88. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  89. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  90. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  91. /* [in] */ const BSTR Superclass,
  92. /* [in] */ long lFlags,
  93. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  94. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  95. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  96. /* [in] */ const BSTR Superclass,
  97. /* [in] */ long lFlags,
  98. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  99. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  100. HRESULT STDMETHODCALLTYPE PutInstance(
  101. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  102. /* [in] */ long lFlags,
  103. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  104. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  105. HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  106. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  107. /* [in] */ long lFlags,
  108. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  109. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  110. HRESULT STDMETHODCALLTYPE DeleteInstance(
  111. /* [in] */ const BSTR ObjectPath,
  112. /* [in] */ long lFlags,
  113. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  114. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  115. HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  116. /* [in] */ const BSTR ObjectPath,
  117. /* [in] */ long lFlags,
  118. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  119. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  120. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  121. /* [in] */ const BSTR Class,
  122. /* [in] */ long lFlags,
  123. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  124. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  125. HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  126. /* [in] */ const BSTR Class,
  127. /* [in] */ long lFlags,
  128. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  129. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  130. HRESULT STDMETHODCALLTYPE ExecQuery(
  131. /* [in] */ const BSTR QueryLanguage,
  132. /* [in] */ const BSTR Query,
  133. /* [in] */ long lFlags,
  134. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  135. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  136. HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  137. /* [in] */ const BSTR QueryLanguage,
  138. /* [in] */ const BSTR Query,
  139. /* [in] */ long lFlags,
  140. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  141. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  142. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  143. /* [in] */ const BSTR QueryLanguage,
  144. /* [in] */ const BSTR Query,
  145. /* [in] */ long lFlags,
  146. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  147. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  148. HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  149. /* [in] */ const BSTR QueryLanguage,
  150. /* [in] */ const BSTR Query,
  151. /* [in] */ long lFlags,
  152. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  153. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  154. HRESULT STDMETHODCALLTYPE ExecMethod( const BSTR, const BSTR, long, IWbemContext*,
  155. IWbemClassObject*, IWbemClassObject**, IWbemCallResult**) {return WBEM_E_NOT_SUPPORTED; };
  156. HRESULT STDMETHODCALLTYPE ExecMethodAsync( const BSTR, const BSTR, long,
  157. IWbemContext*, IWbemClassObject*, IWbemObjectSink*);
  158. };
  159. typedef CClassPro *PCClassPro;
  160. // This class is the class factory for CClassPro objects.
  161. class CProvFactory : public IClassFactory
  162. {
  163. protected:
  164. ULONG m_cRef;
  165. public:
  166. CProvFactory(void);
  167. ~CProvFactory(void);
  168. //IUnknown members
  169. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  170. STDMETHODIMP_(ULONG) AddRef(void);
  171. STDMETHODIMP_(ULONG) Release(void);
  172. //IClassFactory members
  173. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID
  174. , PPVOID);
  175. STDMETHODIMP LockServer(BOOL);
  176. };
  177. typedef CProvFactory *PCProvFactory;
  178. // These variables keep track of when the module can be unloaded
  179. extern LONG g_cObj;
  180. extern LONG g_cLock;
  181. #endif