home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / adsi / sampprov / stdfact.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-29  |  2.0 KB  |  134 lines

  1. /*++
  2.  
  3. Copyright (c) 1996 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     StdFact.cpp
  8.  
  9. Abstract:
  10.  
  11.     Standard IClassFactory implementation
  12.  
  13. Author:
  14.  
  15. Environment:
  16.  
  17.     User mode
  18.  
  19. Revision History :
  20.  
  21. --*/
  22. #include "adssmp.h"
  23.  
  24. STDMETHODIMP
  25. StdClassFactory::QueryInterface(REFIID riid, LPVOID FAR* ppv)
  26. {
  27.     if (!ppv)
  28.         RRETURN(E_INVALIDARG);
  29.  
  30.     if (IsEqualIID(riid, IID_IUnknown) ||
  31.         IsEqualIID(riid, IID_IClassFactory))
  32.     {
  33.         *ppv = (IClassFactory *) this;
  34.     }
  35.     else
  36.     {
  37.         *ppv = NULL;
  38.         return E_NOINTERFACE;
  39.     }
  40.  
  41.     ((IUnknown *)*ppv)->AddRef();
  42.     return S_OK;
  43. }
  44.  
  45. STDMETHODIMP_(ULONG)
  46. StdClassFactory::AddRef(void)
  47. {
  48.     ADsAssert(_ulRefs);
  49.  
  50.     if (_ulRefs == 1)
  51.         INC_OBJECT_COUNT();
  52.  
  53.     return ++_ulRefs;
  54. }
  55.  
  56. STDMETHODIMP_(ULONG)
  57. StdClassFactory::Release(void)
  58. {
  59.     ADsAssert(_ulRefs > 1);
  60.  
  61.     if (--_ulRefs == 1)
  62.         DEC_OBJECT_COUNT();
  63.  
  64.     return _ulRefs;
  65. }
  66.  
  67. STDMETHODIMP
  68. StdClassFactory::LockServer (BOOL fLock)
  69. {
  70.     if (fLock)
  71.         INC_OBJECT_COUNT();
  72.     else
  73.         DEC_OBJECT_COUNT();
  74.     return NOERROR;
  75. }
  76.  
  77. CDynamicCF::CDynamicCF(void)
  78. {
  79.     _ulRefs = 1;
  80.  
  81.     INC_OBJECT_COUNT();
  82. }
  83.  
  84. CDynamicCF::~CDynamicCF(void)
  85. {
  86.     DEC_OBJECT_COUNT();
  87. }
  88.  
  89. STDMETHODIMP
  90. CDynamicCF::QueryInterface(REFIID riid, LPVOID FAR* ppv)
  91. {
  92.     if (!ppv)
  93.         RRETURN(E_INVALIDARG);
  94.  
  95.     if (IsEqualIID(riid, IID_IUnknown) ||
  96.         IsEqualIID(riid, IID_IClassFactory))
  97.     {
  98.         *ppv = (IClassFactory *) this;
  99.     }
  100.     else
  101.     {
  102.         *ppv = NULL;
  103.         return E_NOINTERFACE;
  104.     }
  105.  
  106.     ((IUnknown *)*ppv)->AddRef();
  107.     return S_OK;
  108. }
  109.  
  110. STDMETHODIMP
  111. CDynamicCF::LockServer (BOOL fLock)
  112. {
  113.     if (fLock)
  114.     {
  115.         _ulRefs++;
  116.     }
  117.     else
  118.     {
  119.         _ulRefs--;
  120.     }
  121.  
  122.     return S_OK;
  123. }
  124.  
  125. #ifdef DOCGEN
  126.  
  127. STDMETHODIMP
  128. StdClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
  129.         REFIID iid,
  130.         LPVOID FAR* ppv) {};
  131. #endif  // DOCGEN
  132.  
  133.  
  134.