windows 如何以编程方式将“唤醒时需要密码”的值更改为 false?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6409711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I change the value on "require a password on wakeup" to false programmatically?
提问by sari k
How can I change the value on "require a password on wakeup" to false in power options programmatically using C#. Currently it requires a password to unlock the computer when it wakes from sleep
如何使用 C# 以编程方式在电源选项中将“唤醒时需要密码”的值更改为 false。目前它需要密码才能在计算机从睡眠中唤醒时解锁
by manual: power options-> advanced settings-> balanced-> require a password on wakeup -> on battery:yes plugged in:yes
手动:电源选项-> 高级设置-> 平衡-> 唤醒时需要密码-> 电池:是 已插入:是
回答by Heinzi
The easiest way is by modifying the registry:
最简单的方法是修改注册表:
In the HKEY_CURRENT_USER\Control Panel\Desktop
registry key, change the value of ScreenSaverIsSecure
to 0
.
在HKEY_CURRENT_USER\Control Panel\Desktop
注册表项中,将 的值更改ScreenSaverIsSecure
为0
。
(According to KB 928717, that's the correct registry key for modifying the "Require a password on wakeup" option.)
(根据KB 928717,这是修改“唤醒时需要密码”选项的正确注册表项。)
回答by CodesInChaos
Generally you should use SystemParametersInfowhere available instead of changing the registry yourself.
通常,您应该在可用的情况下使用 SystemParametersInfo而不是自己更改注册表。
Perhaps SystemParametersInfowith the SPI_SETSCREENSAVESECURE
parameter does what you want. It exists only on Vista or later. I haven't tried it myself, but from the description it might be what you want.
也许带有参数的SystemParametersInfo 可以满足SPI_SETSCREENSAVESECURE
您的需求。它仅存在于 Vista 或更高版本上。我自己没有尝试过,但从描述来看,它可能是您想要的。