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.

206 lines
4.1 KiB

  1. //==========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright 1998 - 1999 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------
  11. #include "precomp.h"
  12. //
  13. // Global variables
  14. //
  15. EXTERN_C const GUID CLSID_SyncMgrHandler;
  16. extern UINT g_cRefThisDll; // Reference count of this DLL.
  17. extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CClassFactory::CClassFactory, public
  21. //
  22. // Synopsis: Constructor
  23. //
  24. // Arguments:
  25. //
  26. // Returns:
  27. //
  28. // Modifies:
  29. //
  30. //----------------------------------------------------------------------------
  31. CClassFactory::CClassFactory()
  32. {
  33. m_cRef = 0L;
  34. g_cRefThisDll++;
  35. }
  36. //+---------------------------------------------------------------------------
  37. //
  38. // Member: CClassFactory::~CClassFactory, public
  39. //
  40. // Synopsis: Destructor
  41. //
  42. // Arguments:
  43. //
  44. // Returns:
  45. //
  46. // Modifies:
  47. //
  48. //----------------------------------------------------------------------------
  49. CClassFactory::~CClassFactory()
  50. {
  51. g_cRefThisDll--;
  52. }
  53. //+---------------------------------------------------------------------------
  54. //
  55. // Member: CClassFactory::QueryInterface public
  56. //
  57. // Synopsis:
  58. //
  59. // Arguments:
  60. //
  61. // Returns:
  62. //
  63. // Modifies:
  64. //
  65. //----------------------------------------------------------------------------
  66. STDMETHODIMP CClassFactory::QueryInterface(REFIID riid,
  67. LPVOID FAR *ppv)
  68. {
  69. *ppv = NULL;
  70. // Any interface on this object is the object pointer
  71. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
  72. {
  73. *ppv = (LPCLASSFACTORY)this;
  74. AddRef();
  75. return NOERROR;
  76. }
  77. return E_NOINTERFACE;
  78. }
  79. //+---------------------------------------------------------------------------
  80. //
  81. // Member: CClassFactory::AddRef, public
  82. //
  83. // Synopsis:
  84. //
  85. // Arguments:
  86. //
  87. // Returns:
  88. //
  89. // Modifies:
  90. //
  91. //----------------------------------------------------------------------------
  92. STDMETHODIMP_(ULONG) CClassFactory::AddRef()
  93. {
  94. return ++m_cRef;
  95. }
  96. //+---------------------------------------------------------------------------
  97. //
  98. // Member: CClassFactory::Release, public
  99. //
  100. // Synopsis:
  101. //
  102. // Arguments:
  103. //
  104. // Returns:
  105. //
  106. // Modifies:
  107. //
  108. //----------------------------------------------------------------------------
  109. STDMETHODIMP_(ULONG) CClassFactory::Release()
  110. {
  111. if (--m_cRef)
  112. return m_cRef;
  113. delete this;
  114. return 0L;
  115. }
  116. //+---------------------------------------------------------------------------
  117. //
  118. // Member: CClassFactory::CreateInstance, public
  119. //
  120. // Synopsis:
  121. //
  122. // Arguments:
  123. //
  124. // Returns:
  125. //
  126. // Modifies:
  127. //
  128. //----------------------------------------------------------------------------
  129. STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
  130. REFIID riid,
  131. LPVOID *ppvObj)
  132. {
  133. HRESULT hr = NOERROR;
  134. *ppvObj = NULL;
  135. if (pUnkOuter)
  136. return CLASS_E_NOAGGREGATION;
  137. LPSYNCMGRSYNCHRONIZE pSyncMgrHandler = new CSyncMgrHandler();
  138. if (NULL == pSyncMgrHandler)
  139. return E_OUTOFMEMORY;
  140. hr = pSyncMgrHandler->QueryInterface(riid, ppvObj);
  141. pSyncMgrHandler->Release(); // remove our reference.
  142. return hr;
  143. }
  144. //+---------------------------------------------------------------------------
  145. //
  146. // Member: CClassFactory::LockServer, public
  147. //
  148. // Synopsis:
  149. //
  150. // Arguments:
  151. //
  152. // Returns:
  153. //
  154. // Modifies:
  155. //
  156. //----------------------------------------------------------------------------
  157. STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
  158. {
  159. if (fLock)
  160. {
  161. ++g_cRefThisDll;
  162. }
  163. else
  164. {
  165. --g_cRefThisDll;
  166. }
  167. return NOERROR;
  168. }