简体   繁体   中英

Getting Power Options settings on a remote PC (C#)

I'm trying to obtain the following information regarding Power Options on a remote PC via C#:

  • Time to sleep
  • Time to turn off display
  • Time to turn off hard disk on battery
  • Time to turn off hard disk when plugged in
  • Sleep after on battery
  • Sleep after when plugged in
  • Hibernate after on battery
  • Hibernate after when plugged in

I'm not looking to change those settings: just reading them.
The registries in CURRENTUSER\\Control Panel\\PowerCfg were less than helpful, as none seem to point to the settings above.
I also tried using PowerEnumerate(), but couldn't find a way to make that function work on a remote computer.

How would I go about obtaining the value of these settings from a remote computer?

The scheme in the registry is (unnecessarily) complicated, however:

HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerSettings

contains GUID values for the different settings, and the default values for AC and DC for the stock plans.

The key

HKLM\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes

contains any modifications made to the Power Schemes settings under the GUIDs for each setting group and setting.

HKLM\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\ActivePowerScheme

contains the GUID of the currently active Power Scheme.

I would certainly not change the settings via the registry, but I believe you could read them.

For example, if your active Power Scheme is High Performance, then ActivePowerScheme contains 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c . If you look in PowerSchemes\\8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c and see

0012ee47-9041-4b5d-9b77-535fba8b1442
    6738e2c4-e8a5-4a42-b16a-e040e769756e
        ACSettingIndex  REG_DWORD  0x00000e10 (3600)

then you know the time to turn off the hard disks on AC power is 3600 seconds or 60 minutes.

you need to make use of Power Management Api, here is the example class PowerManager.cs and also look into Power Scheme Management MSDN

Edit: Something that you are seeking to capture the details from the remote PC, you can install your program in window service through which you can read the updates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM