diff --git a/ExplorerPatcher/GUI.c b/ExplorerPatcher/GUI.c index 11905b3..f53839a 100644 --- a/ExplorerPatcher/GUI.c +++ b/ExplorerPatcher/GUI.c @@ -465,6 +465,18 @@ LSTATUS GUI_Internal_RegSetValueExW( { return RegisterDWMService(*(DWORD*)lpData, 0); } + else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_FileExplorerCommandUI")) + { + if (!*(DWORD*)lpData) + { + RegDeleteKeyW(HKEY_CURRENT_USER, L"SOFTWARE\\Classes\\CLSID\\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\\InProcServer32"); + } + else + { + RegSetKeyValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Classes\\CLSID\\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\\InProcServer32", L"", REG_SZ, L"", 1); + } + RegSetKeyValueW(HKEY_CURRENT_USER, _T(REGPATH), L"FileExplorerCommandUI", REG_DWORD, lpData, sizeof(DWORD)); + } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_RegisterAsShellExtension")) { HKEY hKey2 = NULL; @@ -538,7 +550,7 @@ LSTATUS GUI_Internal_RegSetValueExW( } } return ERROR_SUCCESS; - } + } } LSTATUS GUI_RegSetValueExW( @@ -700,6 +712,16 @@ LSTATUS GUI_Internal_RegQueryValueExW( } return ERROR_SUCCESS; } + else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_FileExplorerCommandUI")) + { + if (RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Classes\\CLSID\\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\\InProcServer32", L"", RRF_RT_REG_SZ, NULL, NULL, NULL) != ERROR_SUCCESS) + { + *lpcbData = sizeof(DWORD); + *(DWORD*)lpData = 0; + return ERROR_SUCCESS; + } + return RegQueryValueExW(hKey, L"FileExplorerCommandUI", lpReserved, lpType, lpData, lpcbData); + } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_RegisterAsShellExtension")) { HKEY hKey2 = NULL; diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index a5aa1c4..a00af05 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -81,6 +81,7 @@ DWORD bMonitorOverride = TRUE; DWORD bOpenAtLogon = FALSE; DWORD bClockFlyoutOnWinC = FALSE; DWORD bUseClassicDriveGrouping = FALSE; +DWORD dwFileExplorerCommandUI = 9999; DWORD bDisableImmersiveContextMenu = FALSE; DWORD bClassicThemeMitigations = FALSE; DWORD bWasClassicThemeMitigationsSet = FALSE; @@ -5872,6 +5873,28 @@ void WINAPI LoadSettings(LPARAM lParam) &dwSize ); dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("FileExplorerCommandUI"), + 0, + NULL, + &dwFileExplorerCommandUI, + &dwSize + ); + if (dwFileExplorerCommandUI == 9999) + { + if (IsWindows11()) + { + DWORD bIsWindows11CommandBarDisabled = (RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Classes\\CLSID\\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\\InProcServer32", L"", RRF_RT_REG_SZ, NULL, NULL, NULL) == ERROR_SUCCESS); + RegSetValueExW(hKey, L"FileExplorerCommandUI", 0, REG_DWORD, &bIsWindows11CommandBarDisabled, sizeof(DWORD)); + dwFileExplorerCommandUI = bIsWindows11CommandBarDisabled; + } + else + { + dwFileExplorerCommandUI = 0; + } + } + dwSize = sizeof(DWORD); RegQueryValueExW( hKey, TEXT("DisableImmersiveContextMenu"), @@ -8164,6 +8187,22 @@ HRESULT shell32_DriveTypeCategorizer_CreateInstanceHook(IUnknown* pUnkOuter, REF #pragma endregion +#pragma region "Disable ribbon in File Explorer" +DEFINE_GUID(CLSID_UIRibbonFramework, + 0x926749FA, 0x2615, 0x4987, 0x88, 0x45, 0xC3, 0x3E, 0x65, 0xF2, 0xB9, 0x57); +DEFINE_GUID(IID_UIRibbonFramework, + 0xF4F0385D, 0x6872, 0x43A8, 0xAD, 0x09, 0x4C, 0x33, 0x9C, 0xB3, 0xF5, 0xC5); +HRESULT ExplorerFrame_CoCreateInstanceHook(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv) +{ + if (dwFileExplorerCommandUI == 2 && IsEqualCLSID(rclsid, &CLSID_UIRibbonFramework) && IsEqualIID(riid, &IID_UIRibbonFramework)) + { + return REGDB_E_CLASSNOTREG; + } + return CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv); +} +#pragma endregion + + #pragma region "Change language UI style" #ifdef _WIN64 DEFINE_GUID(CLSID_InputSwitchControl, @@ -9858,6 +9897,10 @@ DWORD Inject(BOOL bIsExplorer) printf("Setup shell32 functions done\n"); + HANDLE hExplorerFrame = GetModuleHandleW(L"ExplorerFrame.dll"); + VnPatchIAT(hExplorerFrame, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", ExplorerFrame_CoCreateInstanceHook); + printf("Setup explorerframe functions done\n"); + if (IsWindows11()) { diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index b8f30c7..992716d 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -158,15 +158,18 @@ ;q ;b Register as shell extension ;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_RegisterAsShellExtension"=dword:00000000 -[-HKEY_CURRENT_USER\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32] -;d Disable the Windows 11 command bar * -@="" [-HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32] ;d Disable the Windows 11 context menu * @="" [HKEY_CURRENT_USER\Software\ExplorerPatcher] ;b Use classic drive groupings in This PC * "UseClassicDriveGrouping"=dword:00000000 +[HKEY_CURRENT_USER\Software\ExplorerPatcher] +;c 3 Control Interface * +;x 0 Windows 11 Command Bar (default) +;x 1 Windows 10 Ribbon +;x 2 Windows 7 Command Bar +;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_FileExplorerCommandUI"=dword:00000000 ;t The following settings take effect on newly created File Explorer windows: [HKEY_CURRENT_USER\Software\ExplorerPatcher] ;i Use immersive menus when displaying Windows 10 context menus ** diff --git a/ExplorerPatcher/settings10.reg b/ExplorerPatcher/settings10.reg index c2e000d..f192edf 100644 --- a/ExplorerPatcher/settings10.reg +++ b/ExplorerPatcher/settings10.reg @@ -142,9 +142,18 @@ ;https://github.com/valinet/ExplorerPatcher/wiki/Using-ExplorerPatcher-as-shell-extension ;q [HKEY_CURRENT_USER\Software\ExplorerPatcher] +;b Register as shell extension +;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_RegisterAsShellExtension"=dword:00000000 +[HKEY_CURRENT_USER\Software\ExplorerPatcher] ;b Use classic drive groupings in This PC * "UseClassicDriveGrouping"=dword:00000000 [HKEY_CURRENT_USER\Software\ExplorerPatcher] +;c 2 Control Interface +;x 0 Windows 10 Ribbon (default) +;x 2 Windows 7 Command Bar +"FileExplorerCommandUI"=dword:00000000 +;t The following settings take effect on newly created File Explorer windows: +[HKEY_CURRENT_USER\Software\ExplorerPatcher] ;i Use immersive menus when displaying Windows 10 context menus ** "DisableImmersiveContextMenu"=dword:00000000 [-HKEY_CURRENT_USER\Software\Classes\CLSID\{056440FD-8568-48e7-A632-72157243B55B}\InprocServer32] @@ -159,9 +168,6 @@ ;p 2 ;b Mica effect on title bar "MicaEffectOnTitlebar"=dword:00000000 -[HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b Register as shell extension -;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_RegisterAsShellExtension"=dword:00000000 ;T Start menu