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.

176 lines
4.4 KiB

  1. //+-------------------------------------------------------------------
  2. // File: ctestcf.cxx
  3. //
  4. // Contents:
  5. //
  6. // Classes: CTestEmbedCF - IClassFactory
  7. //
  8. // History: 7-Dec-92 DeanE Created
  9. //---------------------------------------------------------------------
  10. #pragma optimize("",off)
  11. #include <windows.h>
  12. #include <ole2.h>
  13. #include "testsrv.hxx"
  14. //+-------------------------------------------------------------------
  15. // Member: CTestEmbedCF::CTestEmbedCF()
  16. //
  17. // Synopsis: The constructor for CTestEmbedCF.
  18. //
  19. // Arguments: None
  20. //
  21. // History: 7-Dec-92 DeanE Created
  22. //--------------------------------------------------------------------
  23. CTestEmbedCF::CTestEmbedCF(CTestServerApp *ptsaServer) : _cRef(1)
  24. {
  25. _ptsaServer = ptsaServer;
  26. return;
  27. }
  28. //+-------------------------------------------------------------------
  29. // Member: CTestEmbedCF::~CTestEmbedCF()
  30. //
  31. // Synopsis: The destructor for CTestEmbedCF.
  32. //
  33. // History: 7-Dec-92 DeanE Created
  34. //--------------------------------------------------------------------
  35. CTestEmbedCF::~CTestEmbedCF()
  36. {
  37. _ptsaServer = NULL;
  38. }
  39. //+-------------------------------------------------------------------
  40. // Member: CTestEmbedCF::Create()
  41. //
  42. // Synopsis: Creates a new CTestEmbedCF object.
  43. //
  44. // Arguments: None
  45. //
  46. // History: 7-Dec-92 DeanE Created
  47. //--------------------------------------------------------------------
  48. IClassFactory FAR* CTestEmbedCF::Create(CTestServerApp *ptsaServer)
  49. {
  50. CTestEmbedCF FAR* pteCF = new FAR CTestEmbedCF(ptsaServer);
  51. // if (NULL != pteCF)
  52. // {
  53. // _ptsaServer = ptsaServer;
  54. // }
  55. return(pteCF);
  56. }
  57. //+-------------------------------------------------------------------
  58. // Method: CTestEmbedCF::QueryInterface
  59. //
  60. // Synopsis: Only IUnknown and IClassFactory supported
  61. // return pointer to the actual object
  62. //
  63. // Parameters: [iid] - Interface ID to return.
  64. // [ppv] - Pointer to pointer to object.
  65. //
  66. // Returns: S_OK if iid is supported, or E_NOINTERFACE if not.
  67. //
  68. // History: 7-Dec-92 DeanE Created
  69. //--------------------------------------------------------------------
  70. STDMETHODIMP CTestEmbedCF::QueryInterface(REFIID iid, void FAR * FAR * ppv)
  71. {
  72. if (GuidEqual(iid, IID_IUnknown) || GuidEqual(iid, IID_IClassFactory))
  73. {
  74. *ppv = this;
  75. AddRef();
  76. return(S_OK);
  77. }
  78. else
  79. {
  80. *ppv = NULL;
  81. return(E_NOINTERFACE);
  82. }
  83. }
  84. STDMETHODIMP_(ULONG) CTestEmbedCF::AddRef(void)
  85. {
  86. return ++_cRef;
  87. }
  88. STDMETHODIMP_(ULONG) CTestEmbedCF::Release(void)
  89. {
  90. ULONG cRefs = --_cRef;
  91. if (cRefs == 0)
  92. {
  93. delete this;
  94. }
  95. return cRefs;
  96. }
  97. //+-------------------------------------------------------------------
  98. // Method: CTestEmbedCF::CreateInstance
  99. //
  100. // Synopsis: This is called by Binding process to create the
  101. // actual class object.
  102. //
  103. // Parameters: [pUnkOuter] - Ignored. Affects aggregation.
  104. // [iidInterface] - Interface ID object should support.
  105. // [ppv] - Pointer to the object.
  106. //
  107. // Returns: S_OOM if object couldn't be created, or SCODE from
  108. // QueryInterface call.
  109. //
  110. // History: 7-Dec-92 DeanE Created
  111. //--------------------------------------------------------------------
  112. STDMETHODIMP CTestEmbedCF::CreateInstance(
  113. IUnknown FAR *pUnkOuter,
  114. REFIID iidInterface,
  115. void FAR* FAR *ppv)
  116. {
  117. CTestEmbed FAR *pteObj;
  118. SCODE sc;
  119. pteObj = new FAR CTestEmbed();
  120. if (pteObj == NULL)
  121. {
  122. return(E_OUTOFMEMORY);
  123. }
  124. sc = pteObj->InitObject(_ptsaServer, g_hwndMain);
  125. if (S_OK != sc)
  126. {
  127. delete pteObj;
  128. return(E_OUTOFMEMORY);
  129. }
  130. // Having created the actual object, ensure desired
  131. // interfaces are available.
  132. //
  133. sc = pteObj->QueryInterface(iidInterface, ppv);
  134. // We are done with the CTestEmbed instance - it's now referenced by ppv
  135. pteObj->Release();
  136. return(sc);
  137. }
  138. //+-------------------------------------------------------------------
  139. // Method: CTestEmbedCF::LockServer
  140. //
  141. // Synopsis: What does this do?
  142. //
  143. // Parameters: [fLock] - ???
  144. //
  145. // Returns: ???
  146. //
  147. // History: 7-Dec-92 DeanE Created
  148. //--------------------------------------------------------------------
  149. STDMETHODIMP CTestEmbedCF::LockServer(BOOL fLock)
  150. {
  151. // BUGBUG - What does this do?
  152. return(E_FAIL);
  153. }