我想禁用或启用 Windows XP 开始菜单中的关机
、重新启动
、休眠
和睡眠
选项/7 以编程方式按需(立即)。
使用gpedit.msc
工具并将Remove and Prevent access to Shut Down command
设置为Enabled
/Disabled
会影响启动立即菜单,这些选项根据我的需要显示/隐藏。但我无法编写程序来执行此操作。
我找到了一种编程解决方案,该解决方案正在创建值为 1
的 NoAction
变量,并将其放置在以下注册表路径中:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer< /code>
但这不会立即禁用 Shutdown/etc,并且会影响 explorer.exe
重新启动之后。
我还尝试使用 explorer.exe "nofollow">RefreshPolicyEx, 刷新策略,SHChangeNotify 并广播 WM_SETTINGCHANGE
和 WM_WININICHANGE
,但这些都没有通知浏览器重新读取注册表/策略。
我想使用 组策略 API 会是一个很好的解决方案,但不知道如何使用它。您能给我一个使用组策略 API 应用本地组策略的简单代码吗?
或者,您是否知道任何其他方法可以立即以编程方式启用/禁用关闭/等?
注意:目标平台为Windows XP和Windows 7
I want to disable or enable Shutdown
,Restart
,Hibernate
, and Sleep
options in the start menu of Windows XP/7 programmatically and on demand (immediately).
Using gpedit.msc
tool and setting Remove and prevent access to Shut Down command
to Enabled
/Disabled
affects the start menu imediately and these options are shown/hidden as I want. But I cannot write a program to do this.
I found one programmatic solution that is creating NoAction
variable with value 1
placed in this registry path:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
But this does not disable the Shutdown/etc immediately and affects after the explorer.exe
is restarted.
I also tried notifying explorer.exe
with RefreshPolicyEx, RefreshPolicy, SHChangeNotify and broadcasting WM_SETTINGCHANGE
and WM_WININICHANGE
, but none of these informed explorer to re-read the registry/policies.
I guess using Group Policy API would be a good solution but don't know how to use it. Can you give me a simple code for applying a local group policy with Group Policy API?
Or, Do you know any other way to enable/disable shutdown/etc immediately and programmatically?
Note: The target platforms are Windows XP and Windows 7
发布评论