开发者

.NET Find Windows Sleep Settings

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:

  1. .NET Managed Code
  2. API
  3. 开发者_JAVA技巧
  4. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜