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.

123 lines
3.2 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: qicf.cxx
  4. //
  5. // Contents: test class factory object implementation
  6. //
  7. // Classes: CQIClassFactory
  8. //
  9. // Functions:
  10. //
  11. // History: 23-Nov-92 Rickhi Created
  12. //
  13. //--------------------------------------------------------------------
  14. #include <pch.cxx>
  15. #pragma hdrstop
  16. #include <qicf.hxx> // class definiton
  17. #include <cqi.hxx> // CQI defines
  18. const GUID CLSID_QI =
  19. {0x00000140,0x0000,0x0008,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  20. const GUID CLSID_QIHANDLER =
  21. {0x00000141,0x0000,0x0008,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  22. //+-------------------------------------------------------------------
  23. //
  24. // Member: CQIClassFactory::CQIClassFactory, public
  25. //
  26. // History: 23-Nov-92 Rickhi Created
  27. //
  28. //--------------------------------------------------------------------
  29. CQIClassFactory::CQIClassFactory(REFCLSID rclsid) : _clsid(rclsid)
  30. {
  31. ENLIST_TRACKING(CQIClassFactory);
  32. }
  33. //+-------------------------------------------------------------------
  34. //
  35. // Member: CQIClassFactory::~CQIClassFactory, public
  36. //
  37. // History: 23-Nov-92 Rickhi Created
  38. //
  39. //--------------------------------------------------------------------
  40. CQIClassFactory::~CQIClassFactory(void)
  41. {
  42. // automatic actions do the rest of the work
  43. }
  44. //+-------------------------------------------------------------------
  45. //
  46. // Member: CQIClassFactory::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 CQIClassFactory::QueryInterface(REFIID riid, void **ppUnk)
  55. {
  56. if (IsEqualIID(riid, IID_IUnknown) ||
  57. IsEqualIID(riid, IID_IClassFactory))
  58. {
  59. *ppUnk = (void *)(IClassFactory *) this;
  60. AddRef();
  61. return S_OK;
  62. }
  63. *ppUnk = NULL;
  64. return E_NOINTERFACE;
  65. }
  66. //+-------------------------------------------------------------------
  67. //
  68. // Member: CQIClassFactory::CreateInstance, public
  69. //
  70. // Synopsis: create a new object with the same class
  71. //
  72. // History: 23-Nov-92 Rickhi Created
  73. //
  74. //--------------------------------------------------------------------
  75. STDMETHODIMP CQIClassFactory::CreateInstance(IUnknown *punkOuter,
  76. REFIID riid,
  77. void **ppunkObject)
  78. {
  79. SCODE sc = E_OUTOFMEMORY;
  80. *ppunkObject = NULL; // in case of failure
  81. // create a new object.
  82. IUnknown *pQI = new CQI(_clsid);
  83. if (pQI)
  84. {
  85. // get the interface the caller wants to use
  86. sc = pQI->QueryInterface(riid, ppunkObject);
  87. pQI->Release();
  88. }
  89. return sc;
  90. }
  91. //+-------------------------------------------------------------------
  92. //
  93. // Member: CQIClassFactory::LockServer, public
  94. //
  95. // Synopsis: create a new object with the same class
  96. //
  97. // History: 23-Nov-92 Rickhi Created
  98. //
  99. //--------------------------------------------------------------------
  100. STDMETHODIMP CQIClassFactory::LockServer(BOOL fLock)
  101. {
  102. if (fLock)
  103. GlobalRefs(TRUE);
  104. else
  105. GlobalRefs(FALSE);
  106. return S_OK;
  107. }