From f3a43148273d52765efee7dd1f63baaf74f59a29 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sun, 16 Apr 2017 19:29:27 +0000 Subject: [PATCH] [EXPLORER] -If rshell is present and CBandSiteMenu_CreateInstance or CBandSite_CreateInstance are exported, use them instead of using the one provided by the system. Now we can start developing CBandSite and CBandSiteMenu on windows to implement support for taskbar toolbars. svn path=/trunk/; revision=74329 --- reactos/base/shell/explorer/explorer.cpp | 2 + reactos/base/shell/explorer/precomp.h | 3 + reactos/base/shell/explorer/rshell.cpp | 93 ++++++++++++++---------- reactos/base/shell/explorer/tbsite.cpp | 32 +++----- 4 files changed, 73 insertions(+), 57 deletions(-) diff --git a/reactos/base/shell/explorer/explorer.cpp b/reactos/base/shell/explorer/explorer.cpp index f392dc2e114..cdcdb1ce0d8 100644 --- a/reactos/base/shell/explorer/explorer.cpp +++ b/reactos/base/shell/explorer/explorer.cpp @@ -205,6 +205,8 @@ _tWinMain(IN HINSTANCE hInstance, */ SetProcessShutdownParameters(2, 0); + InitRSHELL(); + #if !WIN7_COMPAT_MODE BOOL CreateShellDesktop = FALSE; diff --git a/reactos/base/shell/explorer/precomp.h b/reactos/base/shell/explorer/precomp.h index 99d5ac3de8a..00c923e40de 100644 --- a/reactos/base/shell/explorer/precomp.h +++ b/reactos/base/shell/explorer/precomp.h @@ -108,11 +108,14 @@ GetExplorerRegValueSet(IN HKEY hKey, * 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 _CBandSiteMenu_CreateInstance(REFIID riid, void **ppv); +HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv); /* * traywnd.c diff --git a/reactos/base/shell/explorer/rshell.cpp b/reactos/base/shell/explorer/rshell.cpp index 3690bbfcbc6..1def6591574 100644 --- a/reactos/base/shell/explorer/rshell.cpp +++ b/reactos/base/shell/explorer/rshell.cpp @@ -20,20 +20,20 @@ #include "precomp.h" -static HINSTANCE hRShell = NULL; +static HINSTANCE ghRShell = NULL; 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); @@ -44,7 +44,7 @@ HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv) NULL, CLSCTX_INPROC_SERVER, riid, - ppv); + ppv); } typedef HANDLE(WINAPI * PSHCREATEDESKTOP)(IShellDesktopTray *ShellDesk); @@ -53,14 +53,9 @@ HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk) { 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); @@ -87,14 +82,9 @@ BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop) { 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); @@ -121,14 +111,9 @@ DWORD WINAPI _WinList_Init(void) { 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(); @@ -155,14 +140,9 @@ void WINAPI _ShellDDEInit(BOOL bInit) { 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); @@ -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); +} + diff --git a/reactos/base/shell/explorer/tbsite.cpp b/reactos/base/shell/explorer/tbsite.cpp index 7ef191d92b6..1cb3ab5a663 100644 --- a/reactos/base/shell/explorer/tbsite.cpp +++ b/reactos/base/shell/explorer/tbsite.cpp @@ -285,26 +285,17 @@ public: IN UINT uFlags, OUT IContextMenu **ppcm) { + HRESULT hRet; + if (m_ContextMenu == NULL) { - HRESULT hRet; - CComPtr pSs; - /* 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; - } - - 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; } @@ -315,7 +306,11 @@ public: } /* 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) @@ -643,10 +638,7 @@ public: m_TaskBand = pTaskBand; /* Create the RebarBandSite */ - hRet = CoCreateInstance(CLSID_RebarBandSite, - static_cast(this), - CLSCTX_INPROC_SERVER, - IID_PPV_ARG(IUnknown, &m_Inner)); + hRet = _CBandSite_CreateInstance(static_cast(this), IID_PPV_ARG(IUnknown, &m_Inner)); if (FAILED_UNEXPECTEDLY(hRet)) return hRet; -- 2.17.1