5

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. Read Registry Value
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143

1 Answers1

0

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

Chris Kooken
  • 32,730
  • 15
  • 85
  • 123