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.

94 lines
2.4 KiB

  1. //***************************************************************************
  2. //
  3. // PROVIDER.CPP
  4. //
  5. // Module: HEALTHMON SERVER AGENT
  6. //
  7. // Purpose: Event consumer provider class implementation
  8. //
  9. // Copyright (c)1999 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #include "stdafx.h"
  13. #include "Provider.h"
  14. #include "Consumer.h"
  15. #include <objbase.h>
  16. CProvider::CProvider()
  17. {
  18. m_cRef = 0L;
  19. }
  20. CProvider::~CProvider()
  21. {
  22. }
  23. STDMETHODIMP CProvider::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  24. {
  25. *ppv=NULL;
  26. if (riid == IID_IUnknown || riid == IID_IWbemEventConsumerProvider)
  27. {
  28. *ppv=this;
  29. }
  30. if (*ppv != NULL)
  31. {
  32. ((LPUNKNOWN)*ppv)->AddRef();
  33. return NOERROR;
  34. }
  35. return E_NOINTERFACE;
  36. }
  37. STDMETHODIMP_(ULONG) CProvider::AddRef(void)
  38. {
  39. return InterlockedIncrement((long*)&m_cRef);
  40. }
  41. STDMETHODIMP_(ULONG) CProvider::Release(void)
  42. {
  43. LONG lCount = InterlockedDecrement((long*)&m_cRef);
  44. if (lCount != 0L)
  45. {
  46. return lCount;
  47. }
  48. delete this;
  49. return 0L;
  50. }
  51. STDMETHODIMP CProvider::Initialize(LPWSTR wszUser, LONG lFlags,
  52. LPWSTR wszNamespace, LPWSTR wszLocale,
  53. IWbemServices __RPC_FAR *pNamespace,
  54. IWbemContext __RPC_FAR *pCtx,
  55. IWbemProviderInitSink __RPC_FAR *pInitSink)
  56. {
  57. // Tell CIMOM that we are initialized
  58. pInitSink->SetStatus(WBEM_S_INITIALIZED, 0);
  59. return WBEM_S_NO_ERROR;
  60. }
  61. //-----------------------------------------------------------
  62. STDMETHODIMP CProvider::FindConsumer(
  63. IWbemClassObject* pLogicalConsumer,
  64. IWbemUnboundObjectSink** ppConsumer)
  65. {
  66. // Singleton Consumer.
  67. static CConsumer Consumer;
  68. // return Consumer.QueryInterface(IID_IWbemUnboundObjectSink, (void**)ppConsumer);
  69. Consumer.QueryInterface(IID_IWbemUnboundObjectSink, (void**)ppConsumer);
  70. // WMI says: It is much more scalable to support IWbemEventConsumerProvider
  71. // interface. In fact, it's even more scalable (M3-only feature!) to return
  72. // S_FALSE from the call to FindConsumer --- in that case we will use NULL
  73. // for the logical consumer pointer in the IndicateToConsumer call.
  74. // By returning S_FALSE you are saying: "I have extracted all the information
  75. // I need from the logical consumer instance and don't care to see it again."
  76. // This way, we don't have to keep it in memory.
  77. return S_FALSE;
  78. }