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.

130 lines
3.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: cqi.cxx
  7. //
  8. // Contents: implementations for QueryInterface test
  9. //
  10. // Functions:
  11. // CQI::CQI
  12. // CQI::~CQI
  13. // CQI::QueryInterface
  14. // CQI::GetClassForHandler
  15. //
  16. // History: 06-Aug-92 Rickhi Created
  17. //
  18. //--------------------------------------------------------------------------
  19. #include <pch.cxx>
  20. #pragma hdrstop
  21. #include <cqi.hxx> // class definition
  22. //+-------------------------------------------------------------------------
  23. //
  24. // Method: CQI::CQI
  25. //
  26. // Synopsis: Creates an instance of CQI
  27. //
  28. // History: 06-Aug-92 Rickhi Created
  29. //
  30. //--------------------------------------------------------------------------
  31. CQI::CQI(REFCLSID rclsid) : _clsid(rclsid)
  32. {
  33. Display(TEXT("CQI created.\n"));
  34. GlobalRefs(TRUE);
  35. ENLIST_TRACKING(CQI);
  36. }
  37. //+-------------------------------------------------------------------------
  38. //
  39. // Method: CQI::~CQI
  40. //
  41. // Synopsis: Cleans up object
  42. //
  43. // History: 06-Aug-92 Rickhi Created
  44. //
  45. //--------------------------------------------------------------------------
  46. CQI::~CQI(void)
  47. {
  48. Display(TEXT("CQI deleted.\n"));
  49. GlobalRefs(FALSE);
  50. // automatic actions are enough
  51. }
  52. //+-------------------------------------------------------------------------
  53. //
  54. // Method: CQI::QueryInterface
  55. //
  56. // Synopsis: returns ptr to requested interface.
  57. //
  58. // DANGER: this returns SUCCESS on almost every interface,
  59. // though the only valid methods on any interface are IUnknown
  60. // and IStdMarshalInfo.
  61. //
  62. // Arguments: [riid] - interface instance requested
  63. // [ppv] - where to put pointer to interface instance
  64. //
  65. // Returns: S_OK or E_NOINTERFACE
  66. //
  67. // History: 06-Aug-92 Rickhi Created
  68. //
  69. //--------------------------------------------------------------------------
  70. STDMETHODIMP CQI::QueryInterface(REFIID riid, void **ppv)
  71. {
  72. if (IsEqualIID(riid, IID_IStdMarshalInfo))
  73. {
  74. if (IsEqualCLSID(_clsid, CLSID_QIHANDLER))
  75. {
  76. *ppv = (IStdMarshalInfo *)this;
  77. AddRef();
  78. return S_OK;
  79. }
  80. }
  81. if (IsEqualIID(riid,IID_IUnknown) ||
  82. IsEqualIID(riid,IID_IAdviseSink) ||
  83. IsEqualIID(riid,IID_IDataObject) ||
  84. IsEqualIID(riid,IID_IOleObject) ||
  85. IsEqualIID(riid,IID_IOleClientSite) ||
  86. IsEqualIID(riid,IID_IParseDisplayName) ||
  87. IsEqualIID(riid,IID_IPersistStorage) ||
  88. IsEqualIID(riid,IID_IPersistFile) ||
  89. IsEqualIID(riid,IID_IStorage) ||
  90. IsEqualIID(riid,IID_IOleContainer) ||
  91. IsEqualIID(riid,IID_IOleItemContainer) ||
  92. IsEqualIID(riid,IID_IOleInPlaceSite) ||
  93. IsEqualIID(riid,IID_IOleInPlaceActiveObject) ||
  94. IsEqualIID(riid,IID_IOleInPlaceObject) ||
  95. IsEqualIID(riid,IID_IOleInPlaceUIWindow) ||
  96. IsEqualIID(riid,IID_IOleInPlaceFrame) ||
  97. IsEqualIID(riid,IID_IOleWindow))
  98. {
  99. *ppv = (void *)(IUnknown *) this;
  100. AddRef();
  101. return S_OK;
  102. }
  103. *ppv = NULL;
  104. return E_NOINTERFACE;
  105. }
  106. //+-------------------------------------------------------------------------
  107. //
  108. // Method: CQI::GetClassForHandler
  109. //
  110. // Synopsis: returns the classid for the inproc handler of this object.
  111. // Used to test handler marshaling.
  112. //
  113. // History: 06-Aug-92 Rickhi Created
  114. //
  115. //--------------------------------------------------------------------------
  116. STDMETHODIMP CQI::GetClassForHandler(DWORD dwDestContext,
  117. void *pvDestContext,
  118. CLSID *pClsid)
  119. {
  120. *pClsid = CLSID_QIHANDLER;
  121. return S_OK;
  122. }