[SHLWAPI][EXPLORER] Implement OS_SERVERADMINUI (#7051)

OS_SERVERADMINUI changes minor things in Explorer, the most visible is that the default folder view mode changes from large icons to details
This commit is contained in:
Whindmar Saksit
2025-09-04 19:25:43 +02:00
committed by GitHub
parent db57e02d6b
commit 87df3ea3e1
14 changed files with 197 additions and 70 deletions

View File

@@ -49,6 +49,31 @@ static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
}
}
static void
InitializeServerAdminUI()
{
HKEY hKey = SHGetShellKey(SHKEY_Root_HKCU | SHKEY_Key_Explorer, L"Advanced", TRUE);
if (!hKey)
return;
DWORD value, size = sizeof(value), type;
DWORD error = SHGetValueW(hKey, NULL, L"ServerAdminUI", &type, &value, &size);
if (error || type != REG_DWORD || size != sizeof(value))
{
// The value doesn't exist or is invalid, calculate and apply a default value
value = IsOS(OS_ANYSERVER) && IsUserAnAdmin();
SHSetValueW(hKey, NULL, L"ServerAdminUI", REG_DWORD, &value, sizeof(value));
if (value)
{
// TODO: Apply registry tweaks with RegInstallW; RegServerAdmin in the REGINST resource in shell32.
#if !ROSPOLICY_SHELL_NODEFKEYBOARDCUES
SystemParametersInfo(SPI_SETKEYBOARDCUES, 0, IntToPtr(TRUE), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
#endif
}
}
RegCloseKey(hKey);
}
#if !WIN7_DEBUG_MODE
static BOOL
SetShellReadyEvent(IN LPCWSTR lpEventName)
@@ -179,6 +204,8 @@ StartWithDesktop(IN HINSTANCE hInstance)
/* Initialize CLSID_ShellWindows class */
_WinList_Init();
InitializeServerAdminUI();
CComPtr<ITrayWindow> Tray;
CreateTrayWindow(&Tray);