开发者

.NET Find Windows Sleep Settings

开发者 https://www.devze.com 2023-04-13 05:36 出处:网络
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?

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

精彩评论

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