-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[New+] Hide existing new - remake #44979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6ba8630
db394ca
65d5fea
94e1c1e
07a9789
7e4be3d
0db150b
90f7d61
3dffe3d
30583f1
fc67460
0b7760d
b64be50
be24d00
68a7b42
ca76278
442463e
3af4201
c173a57
f4c5046
dd36e9b
18061ff
66178d1
d7a17d6
584a52d
9df6dcc
7b7c344
997f846
de8abc4
c44e00b
19a24f3
f68fa9f
f4d41d0
ec4977e
e7cf367
00441c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |||||
| <string id="SUPPORTED_POWERTOYS_0_90_0">PowerToys version 0.90.0 or later</string> | ||||||
| <string id="SUPPORTED_POWERTOYS_0_96_0">PowerToys version 0.96.0 or later</string> | ||||||
| <string id="SUPPORTED_POWERTOYS_0_97_0">PowerToys version 0.97.0 or later</string> | ||||||
| <string id="SUPPORTED_POWERTOYS_0_98_0">PowerToys version 0.98.0 or later</string> | ||||||
| <string id="SUPPORTED_POWERTOYS_0_64_0_TO_0_87_1">From PowerToys version 0.64.0 until PowerToys version 0.87.1</string> | ||||||
|
|
||||||
| <string id="ConfigureAllUtilityGlobalEnabledStateDescription">This policy configures the enabled state for all PowerToys utilities. | ||||||
|
|
@@ -238,7 +239,7 @@ If you disable this policy, the setting is disabled and variables in filenames w | |||||
|
|
||||||
| If you don't configure this policy, the user will be able to control the setting and can enable or disable it. | ||||||
| </string> | ||||||
|
|
||||||
| <string id="ConfigureAllUtilityGlobalEnabledState">Configure global utility enabled state</string> | ||||||
| <string id="ConfigureEnabledUtilityAdvancedPaste">Advanced Paste: Configure enabled state</string> | ||||||
| <string id="ConfigureEnabledUtilityAlwaysOnTop">Always On Top: Configure enabled state</string> | ||||||
|
|
@@ -356,6 +357,15 @@ If you disable this policy, users will not be able to select or use Foundry Loca | |||||
| <string id="AllowDiagnosticData">Allow sending diagnostic data</string> | ||||||
| <string id="ConfigureRunAtStartup">Configure the run at startup setting</string> | ||||||
| <string id="NewPlusReplaceVariablesInTemplateFilenames">Replace variables in template filenames</string> | ||||||
| <string id="NewPlusHideBuiltInNewContextMenu">Hide the built-in "New" context menu</string> | ||||||
| <string id="NewPlusHideBuiltInNewContextMenuDescription">This policy configures if Windows' built-in New context menu should be hidden on the context menu. | ||||||
|
|
||||||
| If you enable this policy, then the built-in New context menu will be hidden, and user can only create new files and folders using New+ and the explorer toolbar New button. | ||||||
|
|
||||||
| If you disable this policy, then the build-in New context menu will be displayed as normal in Windows. | ||||||
|
||||||
| If you disable this policy, then the build-in New context menu will be displayed as normal in Windows. | |
| If you disable this policy, then the built-in New context menu will be displayed as normal in Windows. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -446,4 +446,69 @@ namespace newplus::utilities | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return hr; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| constexpr wchar_t built_in_new_registry_path[] = LR"(Software\Classes\Directory\Background\ShellEx\ContextMenuHandlers\New)"; | ||||||||||||||||||||||||||||
| constexpr wchar_t built_in_new_registry_disabled_value_prefix[] = L"disabled_"; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| inline bool disable_built_in_new_via_registry() | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| // This is implemented to support where New+ GPO is configured to | ||||||||||||||||||||||||||||
| // hide the built-in New context menu but Settings UI hasn't been launched | ||||||||||||||||||||||||||||
| // Mirrors the logic in DisableBuiltInNewViaRegistry in .cs | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| HKEY key{}; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (RegCreateKeyExW(HKEY_CURRENT_USER, | ||||||||||||||||||||||||||||
| built_in_new_registry_path, | ||||||||||||||||||||||||||||
| 0, | ||||||||||||||||||||||||||||
| nullptr, | ||||||||||||||||||||||||||||
| REG_OPTION_NON_VOLATILE, | ||||||||||||||||||||||||||||
| KEY_ALL_ACCESS, | ||||||||||||||||||||||||||||
| nullptr, | ||||||||||||||||||||||||||||
| &key, | ||||||||||||||||||||||||||||
| nullptr) != ERROR_SUCCESS) | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const auto built_in_new_registry_disabled_value_prefix_len = lstrlenW(built_in_new_registry_disabled_value_prefix); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (RegSetValueExW(key, nullptr, 0, REG_SZ, reinterpret_cast<const BYTE*>(&built_in_new_registry_disabled_value_prefix), built_in_new_registry_disabled_value_prefix_len) != ERROR_SUCCESS) | ||||||||||||||||||||||||||||
|
Comment on lines
+475
to
+476
|
||||||||||||||||||||||||||||
| if (RegSetValueExW(key, nullptr, 0, REG_SZ, reinterpret_cast<const BYTE*>(&built_in_new_registry_disabled_value_prefix), built_in_new_registry_disabled_value_prefix_len) != ERROR_SUCCESS) | |
| const DWORD built_in_new_registry_disabled_value_prefix_size = | |
| static_cast<DWORD>((built_in_new_registry_disabled_value_prefix_len + 1) * sizeof(wchar_t)); | |
| if (RegSetValueExW(key, | |
| nullptr, | |
| 0, | |
| REG_SZ, | |
| reinterpret_cast<const BYTE*>(built_in_new_registry_disabled_value_prefix), | |
| built_in_new_registry_disabled_value_prefix_size) != ERROR_SUCCESS) |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reinterpret_cast is taking the address of a pointer (&built_in_new_registry_disabled_value_prefix) instead of using the pointer directly. Since built_in_new_registry_disabled_value_prefix is already a const wchar_t*, you should cast it directly without the address-of operator.
Change to: reinterpret_cast<const BYTE*>(built_in_new_registry_disabled_value_prefix)
See the correct pattern in shell_ext_registration.h line 123 and line 150.
| if (RegSetValueExW(key, nullptr, 0, REG_SZ, reinterpret_cast<const BYTE*>(&built_in_new_registry_disabled_value_prefix), built_in_new_registry_disabled_value_prefix_len) != ERROR_SUCCESS) | |
| if (RegSetValueExW(key, nullptr, 0, REG_SZ, reinterpret_cast<const BYTE*>(built_in_new_registry_disabled_value_prefix), built_in_new_registry_disabled_value_prefix_len) != ERROR_SUCCESS) |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value logic is inverted. The function returns true on RegSetValueExW failure (line 479) and false on success (line 483). This contradicts the boolean return type semantics where true typically indicates success. This should return false on RegSetValueExW failure and true on success to be consistent with standard C++ conventions and the enable_built_in_new_via_registry function which also has inverted return logic.
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value logic appears inverted. The function returns true when registry operations fail (lines 501, 507) and false when they succeed (line 511). This contradicts typical boolean semantics where true indicates success. Consider whether the return values should be swapped to match standard conventions, or if the function is intentionally designed this way, document it clearly with comments.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,22 @@ class NewModule : public PowertoyModuleIface | |
| void init_settings() | ||
| { | ||
| powertoy_new_enabled = NewSettingsInstance().GetEnabled(); | ||
|
|
||
| UpdateRegistration(powertoy_new_enabled); | ||
|
|
||
| if (powertoy_new_enabled) | ||
| { | ||
| // NOTE: This requires that the runner is running and have loaded the new plus module. | ||
| // It's not enough for user to just invoke the context menu. | ||
| if (NewSettingsInstance().GetHideBuiltInNew()) | ||
| { | ||
| newplus::utilities::disable_built_in_new_via_registry(); | ||
| } | ||
| else | ||
| { | ||
| newplus::utilities::enable_built_in_new_via_registry(); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
172
to
191
|
||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgaarden Would you mind opening a PR in the MS Learn docs too with this troubleshooting paragraph?
https://github.com/MicrosoftDocs/windows-dev-docs/blob/docs/hub/powertoys/newplus.md