Improve Start Menu customization.
JIRA issue: CORE-16956
- Add SHSettingsChanged prototype to
<undocshell.h>.
- Add SetRestriction helper function.
- Implement showing/hiding Run menu
item of Start Menu.
BOOL SetRegDword(IN LPCWSTR pszSubKey, IN LPCWSTR pszValueName, IN DWORD dwValue);
BOOL GetAdvancedBool(IN LPCWSTR pszValueName, IN BOOL bDefaultValue);
BOOL SetAdvancedDword(IN LPCWSTR pszValueName, IN DWORD dwValue);
+BOOL SetRestriction(IN LPCWSTR pszKey, IN LPCWSTR pszValueName, IN DWORD dwValue);
/*
* rshell.c
return SetAdvancedDword(entry->name, dwValue);
}
+static DWORD CALLBACK CustomizeReadRun(const CUSTOMIZE_ENTRY *entry)
+{
+ return !SHRestricted(REST_NORUN);
+}
+
+static BOOL CALLBACK CustomizeWriteRest(const CUSTOMIZE_ENTRY *entry, DWORD dwValue)
+{
+ SetRestriction(L"Explorer", entry->name, !dwValue);
+ return TRUE;
+}
+
static const CUSTOMIZE_ENTRY s_CustomizeEntries[] =
{
// FIXME: Make "StartMenuAdminTools" effective
{ IDS_ADVANCED_DISPLAY_FAVORITES, L"StartMenuFavorites", CustomizeRead0, CustomizeWrite0 },
{ IDS_ADVANCED_DISPLAY_LOG_OFF, L"StartMenuLogoff", CustomizeRead0, CustomizeWrite0 },
-
- // FIXME: SHRestricted is buggy!
- //{ IDS_ADVANCED_DISPLAY_RUN, L"NoRun", CustomizeRead2, CustomizeWrite2 },
+ { IDS_ADVANCED_DISPLAY_RUN, L"NoRun", CustomizeReadRun, CustomizeWriteRest },
};
static VOID AddCustomizeItem(HWND hTreeView, const CUSTOMIZE_ENTRY *entry)
/* Run */
if (SHRestricted(REST_NORUN))
{
- DeleteMenu(hMenu,
- IDM_RUN,
- MF_BYCOMMAND);
+ DeleteMenu(hMenu, IDM_RUN, MF_BYCOMMAND);
}
/* Synchronize */
return SetRegDword(REGKEY_ADVANCED, pszValueName, dwValue);
}
+BOOL SetRestriction(IN LPCWSTR pszKey, IN LPCWSTR pszValueName, IN DWORD dwValue)
+{
+ WCHAR szSubKey[MAX_PATH] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
+ PathAppendW(szSubKey, pszKey);
+ SHSetValueW(HKEY_CURRENT_USER, szSubKey, pszValueName, REG_DWORD, &dwValue, sizeof(dwValue));
+ SHSettingsChanged(NULL, NULL);
+ return TRUE;
+}
+
BOOL
GetVersionInfoString(IN LPCWSTR szFileName,
IN LPCWSTR szVersionInfo,
static const LPCWSTR s_pszExplorerKey =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer";
-extern "C"
-BOOL WINAPI SHSettingsChanged(LPCVOID unused, LPCVOID inpRegKey);
-
/////////////////////////////////////////////////////////////////////////////
// Shell settings
#endif /* defined (_SHELLAPI_H) || defined (_INC_SHELLAPI) */
-
/****************************************************************************
* Taskbar WM_COMMAND identifiers
*/
#define TWM_DOEXITWINDOWS (WM_USER + 342)
#define TWM_CYCLEFOCUS (WM_USER + 348)
-
/****************************************************************************
* IDList Functions
*/
BOOL WINAPI StrRetToStrNA(LPSTR,DWORD,LPSTRRET,const ITEMIDLIST*);
BOOL WINAPI StrRetToStrNW(LPWSTR,DWORD,LPSTRRET,const ITEMIDLIST*);
-
/****************************************************************************
* SHChangeNotifyRegister API
*/
/****************************************************************************
* File Menu Routines
*/
+
/* FileMenu_Create nSelHeight constants */
#define FM_DEFAULT_SELHEIGHT -1
#define FM_FULL_SELHEIGHT 0
_In_ LPCWSTR cmdline,
_In_ INT cmdshow);
+BOOL WINAPI SHSettingsChanged(LPCVOID unused, LPCWSTR pszKey);
+
/*****************************************************************************
* Shell32 resources
*/