[EXPLORER] -If rshell is present and CBandSiteMenu_CreateInstance or CBandSite_Create...
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 16 Apr 2017 19:29:27 +0000 (19:29 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 16 Apr 2017 19:29:27 +0000 (19:29 +0000)
svn path=/trunk/; revision=74329

reactos/base/shell/explorer/explorer.cpp
reactos/base/shell/explorer/precomp.h
reactos/base/shell/explorer/rshell.cpp
reactos/base/shell/explorer/tbsite.cpp

index f392dc2..cdcdb1c 100644 (file)
@@ -205,6 +205,8 @@ _tWinMain(IN HINSTANCE hInstance,
     */
     SetProcessShutdownParameters(2, 0);
 
     */
     SetProcessShutdownParameters(2, 0);
 
+    InitRSHELL();
+
 #if !WIN7_COMPAT_MODE
     BOOL CreateShellDesktop = FALSE;
 
 #if !WIN7_COMPAT_MODE
     BOOL CreateShellDesktop = FALSE;
 
index 99d5ac3..00c923e 100644 (file)
@@ -108,11 +108,14 @@ GetExplorerRegValueSet(IN HKEY hKey,
  *  rshell.c
  */
 
  *  rshell.c
  */
 
+VOID InitRSHELL(VOID);
 HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv);
 HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk);
 BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop);
 DWORD WINAPI _WinList_Init(void);
 void WINAPI _ShellDDEInit(BOOL bInit);
 HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv);
 HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk);
 BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop);
 DWORD WINAPI _WinList_Init(void);
 void WINAPI _ShellDDEInit(BOOL bInit);
+HRESULT WINAPI _CBandSiteMenu_CreateInstance(REFIID riid, void **ppv);
+HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
 
 /*
  * traywnd.c
 
 /*
  * traywnd.c
index 3690bbf..1def659 100644 (file)
 
 #include "precomp.h"
 
 
 #include "precomp.h"
 
-static HINSTANCE hRShell = NULL;
+static HINSTANCE ghRShell = NULL;
 
 typedef HRESULT(WINAPI * PSTARTMENU_CONSTRUCTOR)(REFIID riid, void **ppv);
 
 
 typedef HRESULT(WINAPI * PSTARTMENU_CONSTRUCTOR)(REFIID riid, void **ppv);
 
-HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv)
+VOID InitRSHELL(VOID)
 {
 {
-    if (!hRShell)
-    {
-        hRShell = LoadLibraryW(L"rshell.dll");
-    }
+    ghRShell = LoadLibraryW(L"rshell.dll");
+}
 
 
-    if (hRShell)
+HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv)
+{
+    if (ghRShell)
     {
     {
-        PSTARTMENU_CONSTRUCTOR func = (PSTARTMENU_CONSTRUCTOR)GetProcAddress(hRShell, "CStartMenu_Constructor");
+        PSTARTMENU_CONSTRUCTOR func = (PSTARTMENU_CONSTRUCTOR)GetProcAddress(ghRShell, "CStartMenu_Constructor");
         if (func)
         {
             return func(riid, ppv);
         if (func)
         {
             return func(riid, ppv);
@@ -44,7 +44,7 @@ HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv)
                             NULL,
                             CLSCTX_INPROC_SERVER,
                             riid,
                             NULL,
                             CLSCTX_INPROC_SERVER,
                             riid,
-                            ppv);   
+                            ppv);
 }
 
 typedef HANDLE(WINAPI * PSHCREATEDESKTOP)(IShellDesktopTray *ShellDesk);
 }
 
 typedef HANDLE(WINAPI * PSHCREATEDESKTOP)(IShellDesktopTray *ShellDesk);
@@ -53,14 +53,9 @@ HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk)
 {
     HINSTANCE hFallback;
 
 {
     HINSTANCE hFallback;
 
-    if (!hRShell)
+    if (ghRShell)
     {
     {
-        hRShell = LoadLibraryW(L"rshell.dll");
-    }
-
-    if (hRShell)
-    {
-        PSHCREATEDESKTOP func = (PSHCREATEDESKTOP)GetProcAddress(hRShell, "SHCreateDesktop");
+        PSHCREATEDESKTOP func = (PSHCREATEDESKTOP)GetProcAddress(ghRShell, "SHCreateDesktop");
         if (func)
         {
             return func(ShellDesk);
         if (func)
         {
             return func(ShellDesk);
@@ -87,14 +82,9 @@ BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop)
 {
     HINSTANCE hFallback;
 
 {
     HINSTANCE hFallback;
 
-    if (!hRShell)
-    {
-        hRShell = LoadLibraryW(L"rshell.dll");
-    }
-
-    if (hRShell)
+    if (ghRShell)
     {
     {
-        PSHDESKTOPMESSAGELOOP func = (PSHDESKTOPMESSAGELOOP)GetProcAddress(hRShell, "SHDesktopMessageLoop");
+        PSHDESKTOPMESSAGELOOP func = (PSHDESKTOPMESSAGELOOP)GetProcAddress(ghRShell, "SHDesktopMessageLoop");
         if (func)
         {
             return func(hDesktop);
         if (func)
         {
             return func(hDesktop);
@@ -121,14 +111,9 @@ DWORD WINAPI _WinList_Init(void)
 {
     HINSTANCE hFallback;
 
 {
     HINSTANCE hFallback;
 
-    if (!hRShell)
-    {
-        hRShell = LoadLibraryW(L"rshell.dll");
-    }
-
-    if (hRShell)
+    if (ghRShell)
     {
     {
-        PWINLIST_INIT func = (PWINLIST_INIT)GetProcAddress(hRShell, "WinList_Init");
+        PWINLIST_INIT func = (PWINLIST_INIT)GetProcAddress(ghRShell, "WinList_Init");
         if (func)
         {
             return func();
         if (func)
         {
             return func();
@@ -155,14 +140,9 @@ void WINAPI _ShellDDEInit(BOOL bInit)
 {
     HINSTANCE hFallback;
 
 {
     HINSTANCE hFallback;
 
-    if (!hRShell)
+    if (ghRShell)
     {
     {
-        hRShell = LoadLibraryW(L"rshell.dll");
-    }
-
-    if (hRShell)
-    {
-        PSHELLDDEINIT func = (PSHELLDDEINIT)GetProcAddress(hRShell, "ShellDDEInit");
+        PSHELLDDEINIT func = (PSHELLDDEINIT)GetProcAddress(ghRShell, "ShellDDEInit");
         if (func)
         {
             func(bInit);
         if (func)
         {
             func(bInit);
@@ -182,3 +162,42 @@ void WINAPI _ShellDDEInit(BOOL bInit)
         }
     }
 }
         }
     }
 }
+
+typedef HRESULT (WINAPI *CBANDSITEMENU_CREATEINSTANCE)(REFIID riid, void **ppv);
+HRESULT WINAPI _CBandSiteMenu_CreateInstance(REFIID riid, void **ppv)
+{
+    if (ghRShell)
+    {
+        CBANDSITEMENU_CREATEINSTANCE func = (CBANDSITEMENU_CREATEINSTANCE)GetProcAddress(ghRShell, "CBandSiteMenu_CreateInstance");
+        if (func)
+        {
+            return func(riid, ppv);
+        }
+    }
+
+    return CoCreateInstance(CLSID_BandSiteMenu,
+                            NULL,
+                            CLSCTX_INPROC_SERVER,
+                            riid,
+                            ppv);
+}
+
+typedef HRESULT (WINAPI *CBANDSITE_CREATEINSTANCE)(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
+HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv)
+{
+    if (ghRShell)
+    {
+        CBANDSITE_CREATEINSTANCE func = (CBANDSITE_CREATEINSTANCE)GetProcAddress(ghRShell, "CBandSite_CreateInstance");
+        if (func)
+        {
+            return func(pUnkOuter, riid, ppv);
+        }
+    }
+
+    return CoCreateInstance(CLSID_RebarBandSite,
+                            pUnkOuter,
+                            CLSCTX_INPROC_SERVER,
+                            riid,
+                            ppv);
+}
+
index 7ef191d..1cb3ab5 100644 (file)
@@ -285,26 +285,17 @@ public:
         IN UINT uFlags,
         OUT IContextMenu **ppcm)
     {
         IN UINT uFlags,
         OUT IContextMenu **ppcm)
     {
+        HRESULT hRet;
+
         if (m_ContextMenu == NULL)
         {
         if (m_ContextMenu == NULL)
         {
-            HRESULT hRet;
-            CComPtr<IShellService> pSs;
-
             /* Cache the context menu so we don't need to CoCreateInstance all the time... */
             /* Cache the context menu so we don't need to CoCreateInstance all the time... */
-            hRet = CoCreateInstance(CLSID_BandSiteMenu, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellService, &pSs));
-            TRACE("CoCreateInstance(CLSID_BandSiteMenu) for IShellService returned: 0x%x\n", hRet);
-            if (!SUCCEEDED(hRet))
-                return hRet;
-
-            hRet = pSs->SetOwner((IBandSite*)this);
-            if (!SUCCEEDED(hRet))
-            {
+            hRet = _CBandSiteMenu_CreateInstance(IID_PPV_ARG(IContextMenu, &m_ContextMenu));
+            if (FAILED_UNEXPECTEDLY(hRet))
                 return hRet;
                 return hRet;
-            }
-
-            hRet = pSs->QueryInterface(IID_PPV_ARG(IContextMenu, &m_ContextMenu));
 
 
-            if (!SUCCEEDED(hRet))
+            hRet = IUnknown_SetOwner(m_ContextMenu, (IBandSite*)this);
+            if (FAILED_UNEXPECTEDLY(hRet))
                 return hRet;
         }
 
                 return hRet;
         }
 
@@ -315,7 +306,11 @@ public:
         }
 
         /* Add the menu items */
         }
 
         /* Add the menu items */
-        return m_ContextMenu->QueryContextMenu(hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
+        hRet = m_ContextMenu->QueryContextMenu(hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
+        if (FAILED_UNEXPECTEDLY(hRet))
+            return hRet;
+
+        return S_OK;
     }
 
     virtual HRESULT STDMETHODCALLTYPE Lock(IN BOOL bLock)
     }
 
     virtual HRESULT STDMETHODCALLTYPE Lock(IN BOOL bLock)
@@ -643,10 +638,7 @@ public:
         m_TaskBand = pTaskBand;
 
         /* Create the RebarBandSite */
         m_TaskBand = pTaskBand;
 
         /* Create the RebarBandSite */
-        hRet = CoCreateInstance(CLSID_RebarBandSite,
-                                static_cast<IBandSite*>(this),
-                                CLSCTX_INPROC_SERVER,
-                                IID_PPV_ARG(IUnknown, &m_Inner));
+        hRet = _CBandSite_CreateInstance(static_cast<IBandSite*>(this), IID_PPV_ARG(IUnknown, &m_Inner));
         if (FAILED_UNEXPECTEDLY(hRet))
             return hRet;
 
         if (FAILED_UNEXPECTEDLY(hRet))
             return hRet;