Leaked source code of windows server 2003
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.

55 lines
1.4 KiB

  1. #include "CUnknown.h"
  2. #include "CFactory.h"
  3. long CUnknown::s_cActiveComponents = 0 ;
  4. CUnknown::CUnknown()
  5. : m_cRef(1)
  6. {
  7. ::InterlockedIncrement(&s_cActiveComponents) ;
  8. }
  9. CUnknown::~CUnknown()
  10. {
  11. ::InterlockedDecrement(&s_cActiveComponents) ;
  12. // If this is an EXE server, shut it down.
  13. CFactory::CloseExe() ;
  14. }
  15. // ---------------------------------------------------------------------------
  16. // AddRef
  17. // ---------------------------------------------------------------------------
  18. DWORD CUnknown::AddRef()
  19. {
  20. return InterlockedIncrement ((LONG*) &m_cRef);
  21. }
  22. // ---------------------------------------------------------------------------
  23. // Release
  24. // ---------------------------------------------------------------------------
  25. DWORD CUnknown::Release()
  26. {
  27. ULONG lRet = InterlockedDecrement ((LONG*) &m_cRef);
  28. if (!lRet)
  29. delete this;
  30. return lRet;
  31. }
  32. // ---------------------------------------------------------------------------
  33. // Release
  34. // ---------------------------------------------------------------------------
  35. DWORD CUnknown::ActiveComponents()
  36. {
  37. return s_cActiveComponents;
  38. }
  39. // ---------------------------------------------------------------------------
  40. // FinishQI
  41. // ---------------------------------------------------------------------------
  42. HRESULT CUnknown::FinishQI(IUnknown* pI, void** ppv)
  43. {
  44. *ppv = pI ;
  45. pI->AddRef() ;
  46. return S_OK ;
  47. }