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.

159 lines
4.2 KiB

  1. /**************************************************************************
  2. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. PARTICULAR PURPOSE.
  6. Copyright 1998 Microsoft Corporation. All Rights Reserved.
  7. **************************************************************************/
  8. /**************************************************************************
  9. File: ClsFact.cpp
  10. Description: Implements CClassFactory.
  11. **************************************************************************/
  12. /**************************************************************************
  13. #include statements
  14. **************************************************************************/
  15. #include "ClsFact.h"
  16. /**************************************************************************
  17. private function prototypes
  18. **************************************************************************/
  19. /**************************************************************************
  20. global variables
  21. **************************************************************************/
  22. ///////////////////////////////////////////////////////////////////////////
  23. //
  24. // IClassFactory implementation
  25. //
  26. /**************************************************************************
  27. CClassFactory::CClassFactory
  28. **************************************************************************/
  29. CClassFactory::CClassFactory()
  30. {
  31. g_DllRefCount++;
  32. m_ObjRefCount = 1;
  33. }
  34. /**************************************************************************
  35. CClassFactory::~CClassFactory
  36. **************************************************************************/
  37. CClassFactory::~CClassFactory()
  38. {
  39. g_DllRefCount--;
  40. }
  41. /**************************************************************************
  42. CClassFactory::QueryInterface
  43. **************************************************************************/
  44. STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppReturn)
  45. {
  46. *ppReturn = NULL;
  47. if(IsEqualIID(riid, IID_IUnknown))
  48. {
  49. *ppReturn = this;
  50. }
  51. else if(IsEqualIID(riid, IID_IClassFactory))
  52. {
  53. *ppReturn = (IClassFactory*)this;
  54. }
  55. if(*ppReturn)
  56. {
  57. (*(LPUNKNOWN*)ppReturn)->AddRef();
  58. return S_OK;
  59. }
  60. return E_NOINTERFACE;
  61. }
  62. /**************************************************************************
  63. CClassFactory::AddRef
  64. **************************************************************************/
  65. STDMETHODIMP_(DWORD) CClassFactory::AddRef()
  66. {
  67. return ++m_ObjRefCount;
  68. }
  69. /**************************************************************************
  70. CClassFactory::Release
  71. **************************************************************************/
  72. STDMETHODIMP_(DWORD) CClassFactory::Release()
  73. {
  74. if(--m_ObjRefCount == 0)
  75. {
  76. delete this;
  77. return 0;
  78. }
  79. return m_ObjRefCount;
  80. }
  81. /**************************************************************************
  82. CClassFactory::CreateInstance
  83. **************************************************************************/
  84. STDMETHODIMP CClassFactory::CreateInstance( LPUNKNOWN pUnknown,
  85. REFIID riid,
  86. LPVOID *ppObject)
  87. {
  88. *ppObject = NULL;
  89. if(pUnknown != NULL)
  90. return CLASS_E_NOAGGREGATION;
  91. //add implementation specific code here
  92. CShellFolder *pShellFolder = new CShellFolder();
  93. if(NULL == pShellFolder)
  94. return E_OUTOFMEMORY;
  95. //get the QueryInterface return for our return value
  96. HRESULT hResult = pShellFolder->QueryInterface(riid, ppObject);
  97. //call Release to decement the ref count
  98. pShellFolder->Release();
  99. //return the result from QueryInterface
  100. return hResult;
  101. }
  102. /**************************************************************************
  103. CClassFactory::LockServer
  104. **************************************************************************/
  105. STDMETHODIMP CClassFactory::LockServer(BOOL)
  106. {
  107. return E_NOTIMPL;
  108. }