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.

135 lines
2.5 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1992-1999 Microsoft Corporation
  4. //
  5. // File: cwmiextcf.cpp
  6. //
  7. // Description :
  8. // ADs "Wbem Provider" class factory
  9. //
  10. // Part of : Wbem ADs Requester oledsreq.dll
  11. //
  12. // History:
  13. // corinaf 10/15/95 Created
  14. //
  15. //***************************************************************************
  16. #include "precomp.h"
  17. extern ULONG g_ulObjCount;
  18. CWMIExtensionCF::CWMIExtensionCF()
  19. {
  20. m_cRef=0L;
  21. g_ulObjCount++;
  22. }
  23. CWMIExtensionCF::~CWMIExtensionCF()
  24. {
  25. g_ulObjCount--;
  26. }
  27. //IUnknown methods
  28. STDMETHODIMP CWMIExtensionCF::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  29. {
  30. *ppv=NULL;
  31. if (riid == IID_IUnknown || riid == IID_IClassFactory)
  32. *ppv=this;
  33. if (*ppv != NULL)
  34. {
  35. ((LPUNKNOWN)*ppv)->AddRef();
  36. return NOERROR;
  37. }
  38. return E_NOINTERFACE;
  39. }
  40. STDMETHODIMP_(ULONG) CWMIExtensionCF::AddRef(void)
  41. {
  42. return ++m_cRef;
  43. }
  44. STDMETHODIMP_(ULONG) CWMIExtensionCF::Release(void)
  45. {
  46. if (--m_cRef != 0L)
  47. return m_cRef;
  48. delete this;
  49. return 0L;
  50. }
  51. //+---------------------------------------------------------------------------
  52. //
  53. // Function: CWMIExtensionCF::CreateInstance
  54. //
  55. // Synopsis:
  56. //
  57. // Arguments: [pUnkOuter]
  58. // [iid]
  59. // [ppv]
  60. //
  61. // Returns: HRESULT
  62. //
  63. // Modifies:
  64. //
  65. // History: 10/20/98 corinaf
  66. //----------------------------------------------------------------------------
  67. STDMETHODIMP
  68. CWMIExtensionCF::CreateInstance(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
  69. {
  70. HRESULT hr;
  71. IUnknown *pExtension = NULL;
  72. //Create the extension and get the IUnknown pointer to it
  73. hr = CWMIExtension::CreateExtension(pUnkOuter, (void **)&pExtension);
  74. if FAILED(hr)
  75. return hr;
  76. if (pExtension)
  77. {
  78. hr = pExtension->QueryInterface(riid, ppv);
  79. pExtension->Release();
  80. }
  81. else
  82. {
  83. *ppv = NULL;
  84. return E_OUTOFMEMORY;
  85. }
  86. return NOERROR;
  87. }
  88. //+---------------------------------------------------------------------------
  89. //
  90. // Function: CWbemProviderCF::LockServer
  91. //
  92. // Synopsis:
  93. //
  94. // Arguments: [fLock]
  95. //
  96. // Returns: HRESULT
  97. //
  98. // Modifies:
  99. //
  100. // History: 10/20/98 corinaf
  101. //----------------------------------------------------------------------------
  102. STDMETHODIMP CWMIExtensionCF::LockServer(BOOL fLock)
  103. {
  104. if (fLock)
  105. m_cRef++;
  106. else
  107. m_cRef--;
  108. return NOERROR;
  109. }