[BROWSEUI] Add locked toolbar state persistence (#5350)

Store the state of the explorer toolbar, locked or unlocked, in the proper
registry location and set the proper toolbar state when initialized.

CORE-9094

- Set `HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\Locked`
  to 1 when the explorer toolbar is locked, 0 when the toolbar is unlocked.
- Query `HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\Locked`
  when the toolbar is initialized to set the correct locked state.
- Set the default state of the toolbar to locked if the registry key does not
  exist, matching the behavior of Windows Server 2003.
This commit is contained in:
Carl J. Bialorucki 2023-06-20 03:16:23 -06:00 committed by GitHub
parent 157491e297
commit f203ad5cf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -607,8 +607,12 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::CallbackSM(LPSMDATA psmd, UINT uMsg, WP
CInternetToolbar::CInternetToolbar()
{
fLocked = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Toolbar",
L"Locked",
FALSE,
TRUE);
fMainReBar = NULL;
fLocked = false;
fMenuBandWindow = NULL;
fNavigationWindow = NULL;
fMenuCallback = new CComObject<CMenuCallback>();
@ -718,7 +722,15 @@ HRESULT CInternetToolbar::LockUnlockToolbars(bool locked)
if (locked != fLocked)
{
DWORD dwLocked = locked ? 1 : 0;
SHRegSetUSValueW(L"Software\\Microsoft\\Internet Explorer\\Toolbar",
L"Locked",
REG_DWORD,
&dwLocked,
sizeof(dwLocked),
SHREGSET_FORCE_HKCU);
fLocked = locked;
rebarBandInfo.cbSize = sizeof(rebarBandInfo);
rebarBandInfo.fMask = RBBIM_STYLE | RBBIM_LPARAM;
bandCount = (int)SendMessage(fMainReBar, RB_GETBANDCOUNT, 0, 0);