I would like to find out what the current windows sleep mode setting is i.e. Is it switched on and what is the timer period. Any ideas?
My preferences (in order) are:
- .NET Managed Code
- API 开发者_JAVA技巧
- Read Registry Value
Here is where it is stored in the registry:
[HKEY_CURRENT_USER\Control Panel\PowerCfg] "CurrentPowerPolicy"="2"
Power Scheme (Default="0")
"0" = Home/Office Desk
"1" = Portable/Laptop
"2" = Presentation
"3" = Always On
"4" = Minimal Power Management
"5" = Max Battery
Then Access it:
RegistryKey key= Registry.CurrentUser.OpenSubKey("Control Panel\PowerCfg", true);
var value = key.GetValue("CurrentPowerPolicy", 0);
There is also a key called Policies that is REG_BINARY
that stores all the specific information. You can use the example on this page to read it: http://www.eggheadcafe.com/community/aspnet/2/13312/registry-access-for-regbinary-values.aspx
精彩评论