diff --git a/base/shell/explorer/precomp.h b/base/shell/explorer/precomp.h index 4b188400861..8ebe8d41cd6 100644 --- a/base/shell/explorer/precomp.h +++ b/base/shell/explorer/precomp.h @@ -353,6 +353,8 @@ UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup, */ VOID ShowCustomizeClassic(HINSTANCE, HWND); +VOID +ClearRecentAndMru(); /* * startmnusite.cpp diff --git a/base/shell/explorer/startmnucust.cpp b/base/shell/explorer/startmnucust.cpp index 44f5b02e7c5..3f267c20ff9 100644 --- a/base/shell/explorer/startmnucust.cpp +++ b/base/shell/explorer/startmnucust.cpp @@ -58,10 +58,53 @@ static BOOL RecentHasShortcut(HWND hwnd) return TRUE; } -static VOID OnClearRecentItems(HWND hwnd) +static const PCWSTR g_MruKeys[] = +{ + L"Software\\Microsoft\\Internet Explorer\\TypedURLs", + L"Explorer\\RunMRU", + L"Explorer\\Comdlg32\\OpenSaveMRU", + L"Explorer\\Comdlg32\\LastVisitedMRU", +}; + +static BOOL HandleMruData(BOOL Delete) +{ + for (UINT i = 0; i < _countof(g_MruKeys); ++i) + { + WCHAR szKey[200]; + PCWSTR pszKey = g_MruKeys[i]; + if (*pszKey != 'S') // Keys not starting with S[oftware] are assumed to be relative to "SMWCV" + { + wsprintfW(szKey, L"%s\\%s", L"Software\\Microsoft\\Windows\\CurrentVersion", pszKey); + pszKey = szKey; + } + + HKEY hKey; + if (Delete) + { + SHDeleteKeyW(HKEY_CURRENT_USER, pszKey); + } + else if (RegOpenKeyExW(HKEY_CURRENT_USER, pszKey, 0, KEY_WRITE, &hKey) == ERROR_SUCCESS) + { + RegCloseKey(hKey); + return TRUE; + } + } + return FALSE; +} + +VOID ClearRecentAndMru() { SHAddToRecentDocs(SHARD_PIDL, NULL); - EnableWindow(GetDlgItem(hwnd, IDC_CLASSICSTART_CLEAR), RecentHasShortcut(hwnd)); + HandleMruData(TRUE); +} + +static VOID InitializeClearButton(HWND hwnd) +{ + HWND hWndClear = GetDlgItem(hwnd, IDC_CLASSICSTART_CLEAR); + BOOL bHasData = RecentHasShortcut(hwnd) || HandleMruData(FALSE); + if (!bHasData && hWndClear == GetFocus()) + SendMessage(hwnd, WM_NEXTDLGCTL, 0, FALSE); + EnableWindow(hWndClear, bHasData); } struct CUSTOM_ENTRY; @@ -175,7 +218,7 @@ static VOID AddCustomItem(HWND hTreeView, const CUSTOM_ENTRY *entry) static void CustomizeClassic_OnInitDialog(HWND hwnd) { - EnableWindow(GetDlgItem(hwnd, IDC_CLASSICSTART_CLEAR), RecentHasShortcut(hwnd)); + InitializeClearButton(hwnd); HWND hTreeView = GetDlgItem(hwnd, IDC_CLASSICSTART_SETTINGS); @@ -240,7 +283,8 @@ INT_PTR CALLBACK CustomizeClassicProc(HWND hwnd, UINT Message, WPARAM wParam, LP OnAdvancedStartMenuItems(); break; case IDC_CLASSICSTART_CLEAR: - OnClearRecentItems(hwnd); + ClearRecentAndMru(); + InitializeClearButton(hwnd); break; case IDOK: if (CustomizeClassic_OnOK(hwnd)) diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp index dfccd130917..9b715b5eca2 100644 --- a/base/shell/explorer/traywnd.cpp +++ b/base/shell/explorer/traywnd.cpp @@ -470,6 +470,9 @@ public: return; SendMessage(m_DesktopWnd, WM_PROGMAN_SAVESTATE, 0, 0); + + if (SHRestricted(REST_CLEARRECENTDOCSONEXIT)) + ClearRecentAndMru(); } LRESULT DoExitWindows()