[RSHELL]
[reactos.git] / base / shell / rshell / CMenuSite.cpp
index 367909c..a90c89b 100644 (file)
@@ -103,7 +103,11 @@ HRESULT STDMETHODCALLTYPE CMenuSite::AddBand(IUnknown * punk)
 
 #define TO_HRESULT(x) ((HRESULT)(S_OK+(x)))
 
 
 #define TO_HRESULT(x) ((HRESULT)(S_OK+(x)))
 
-    if (SHIsSameObject(punk, m_BandObject))
+    CComPtr<IUnknown> pUnknown;
+
+    punk->QueryInterface(IID_PPV_ARG(IUnknown, &pUnknown));
+
+    if (pUnknown == m_BandObject)
         return TO_HRESULT(0);
 
     if (m_BandObject)
         return TO_HRESULT(0);
 
     if (m_BandObject)
@@ -118,28 +122,26 @@ HRESULT STDMETHODCALLTYPE CMenuSite::AddBand(IUnknown * punk)
     m_WinEventHandler = NULL;
     m_hWndBand = NULL;
 
     m_WinEventHandler = NULL;
     m_hWndBand = NULL;
 
-    if (!punk)
+    if (!pUnknown)
         return TO_HRESULT(0);
 
         return TO_HRESULT(0);
 
-    hr = punk->QueryInterface(IID_PPV_ARG(IDeskBand, &m_DeskBand));
+    hr = pUnknown->QueryInterface(IID_PPV_ARG(IDeskBand, &m_DeskBand));
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
-    hr = punk->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_WinEventHandler));
+    hr = pUnknown->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_WinEventHandler));
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
-    hr = IUnknown_SetSite(punk, this->ToIUnknown());
+    hr = IUnknown_SetSite(pUnknown, this->ToIUnknown());
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
-    hr = IUnknown_GetWindow(punk, &m_hWndBand);
+    hr = IUnknown_GetWindow(pUnknown, &m_hWndBand);
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
-    m_BandObject = punk;
-
-    punk->AddRef();
+    m_BandObject = pUnknown;
 
     return TO_HRESULT(0);
 }
 
     return TO_HRESULT(0);
 }
@@ -250,13 +252,13 @@ HRESULT STDMETHODCALLTYPE CMenuSite::QueryService(REFGUID guidService, REFIID ri
         IsEqualGUID(guidService, SID_SMenuBandChild))
     {
         if (m_BandObject == NULL)
         IsEqualGUID(guidService, SID_SMenuBandChild))
     {
         if (m_BandObject == NULL)
-            return E_FAIL;
+            return E_NOINTERFACE;
 
         return IUnknown_QueryService(m_BandObject, guidService, riid, ppvObject);
     }
 
     if (!m_DeskBarSite)
 
         return IUnknown_QueryService(m_BandObject, guidService, riid, ppvObject);
     }
 
     if (!m_DeskBarSite)
-        return E_FAIL;
+        return E_NOINTERFACE;
 
     return IUnknown_QueryService(m_DeskBarSite, guidService, riid, ppvObject);
 }
 
     return IUnknown_QueryService(m_DeskBarSite, guidService, riid, ppvObject);
 }