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.

141 lines
3.1 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: loopscf.cxx
  4. //
  5. // Contents: test class factory object implementation
  6. //
  7. // Classes: CLoopClassFactory
  8. //
  9. // History: 23-Nov-92 Rickhi Created
  10. //
  11. //--------------------------------------------------------------------
  12. #include <pch.cxx>
  13. #pragma hdrstop
  14. #include <loopscf.hxx> // class definiton
  15. #include <cloop.hxx> // CLoop defines
  16. const GUID CLSID_Loop =
  17. {0x0000013c,0x0001,0x0008,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  18. //+-------------------------------------------------------------------
  19. //
  20. // Member: CLoopClassFactory::CLoopClassFactory, public
  21. //
  22. // Algorithm:
  23. //
  24. // History: 23-Nov-92 Rickhi Created
  25. //
  26. //--------------------------------------------------------------------
  27. CLoopClassFactory::CLoopClassFactory(void)
  28. {
  29. ENLIST_TRACKING(CLoopClassFactory);
  30. }
  31. //+-------------------------------------------------------------------
  32. //
  33. // Member: CLoopClassFactory::~CLoopClassFactory, public
  34. //
  35. // Algorithm:
  36. //
  37. // History: 23-Nov-92 Rickhi Created
  38. //
  39. //--------------------------------------------------------------------
  40. CLoopClassFactory::~CLoopClassFactory(void)
  41. {
  42. // automatic actions do the rest of the work
  43. }
  44. //+-------------------------------------------------------------------
  45. //
  46. // Member: CLoopClassFactory::QueryInterface, public
  47. //
  48. // Algorithm: if the interface is not one implemented by us,
  49. // pass the request to the proxy manager
  50. //
  51. // History: 23-Nov-92 Rickhi Created
  52. //
  53. //--------------------------------------------------------------------
  54. STDMETHODIMP CLoopClassFactory::QueryInterface(REFIID riid, void **ppUnk)
  55. {
  56. SCODE sc = S_OK;
  57. if (IsEqualIID(riid, IID_IUnknown) ||
  58. IsEqualIID(riid, IID_IClassFactory))
  59. {
  60. *ppUnk = (void *)(IClassFactory *) this;
  61. AddRef();
  62. }
  63. else
  64. {
  65. *ppUnk = NULL;
  66. sc = E_NOINTERFACE;
  67. }
  68. return sc;
  69. }
  70. //+-------------------------------------------------------------------
  71. //
  72. // Member: CLoopClassFactory::CreateInstance, public
  73. //
  74. // Synopsis: create a new object with the same class
  75. //
  76. // History: 23-Nov-92 Rickhi Created
  77. //
  78. //--------------------------------------------------------------------
  79. STDMETHODIMP CLoopClassFactory::CreateInstance(IUnknown *punkOuter,
  80. REFIID riid,
  81. void **ppunkObject)
  82. {
  83. SCODE sc = E_OUTOFMEMORY;
  84. *ppunkObject = NULL; // in case of failure
  85. // create a ball object.
  86. IUnknown *punk = (IUnknown *) new CLoop();
  87. if (punk)
  88. {
  89. // get the interface the caller wants to use
  90. sc = punk->QueryInterface(riid, ppunkObject);
  91. // release our hold on the ball, since the QI got a hold for
  92. // the client.
  93. punk->Release();
  94. }
  95. return sc;
  96. }
  97. //+-------------------------------------------------------------------
  98. //
  99. // Member: CLoopClassFactory::LockServer, public
  100. //
  101. // Synopsis: create a new object with the same class
  102. //
  103. // History: 23-Nov-92 Rickhi Created
  104. //
  105. //--------------------------------------------------------------------
  106. STDMETHODIMP CLoopClassFactory::LockServer(BOOL fLock)
  107. {
  108. if (fLock)
  109. GlobalRefs(TRUE);
  110. else
  111. GlobalRefs(FALSE);
  112. return S_OK;
  113. }