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.

140 lines
3.3 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: rpccf.cxx
  4. //
  5. // Contents: rpc test class factory object implementation
  6. //
  7. // Classes: CRpcTestClassFactory
  8. //
  9. // History: 23-Nov-92 Rickhi Created
  10. //
  11. //--------------------------------------------------------------------
  12. #include <pch.cxx>
  13. #pragma hdrstop
  14. #include <rpccf.hxx> // class definiton
  15. #include <crpc.hxx> // CRpcTests defines
  16. const GUID CLSID_RpcTest =
  17. {0x0000013d,0x0001,0x0008,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  18. //+-------------------------------------------------------------------
  19. //
  20. // Member: CRpcTestClassFactory::CRpcTestClassFactory, public
  21. //
  22. // Algorithm:
  23. //
  24. // History: 23-Nov-92 Rickhi Created
  25. //
  26. //--------------------------------------------------------------------
  27. CRpcTestClassFactory::CRpcTestClassFactory(void)
  28. {
  29. ENLIST_TRACKING(CRpcTestClassFactory);
  30. }
  31. //+-------------------------------------------------------------------
  32. //
  33. // Member: CRpcTestClassFactory::~CRpcTestClassFactory, public
  34. //
  35. // Algorithm:
  36. //
  37. // History: 23-Nov-92 Rickhi Created
  38. //
  39. //--------------------------------------------------------------------
  40. CRpcTestClassFactory::~CRpcTestClassFactory(void)
  41. {
  42. // automatic actions do the rest of the work
  43. }
  44. //+-------------------------------------------------------------------
  45. //
  46. // Member: CRpcTestClassFactory::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 CRpcTestClassFactory::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: CRpcTestClassFactory::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 CRpcTestClassFactory::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 CRpcTest();
  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: CRpcTestClassFactory::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 CRpcTestClassFactory::LockServer(BOOL fLock)
  107. {
  108. if (fLock)
  109. GlobalRefs(TRUE);
  110. else
  111. GlobalRefs(FALSE);
  112. return S_OK;
  113. }