Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I would like to know how to get the power policy (or power scheme) values of the current energy plan set by an user in Windows, such as minutes left to sleep (S3) and minutes left to hibernate (S4).

How could I get the real values given by the user for a power policy scheme?

Im working under Windows 7 and Visual Studio C++ (I could use C#, a command line by cmd or whatever).

Kind regards

What I have tried:

I tried with powercfg, and the closer I get is using GLOBAL_POWER_POLICY, POWER_POLICY and GetCurrentPowerPolicies. But the values are not the expected minutes given by the user in Control Panel, Energy Options.

I understand that powerPolicy.user.IdleTimeoutAc is not the sleep (S3) time left, is the time to fire the S3 or S4 event, and I can't know if it that value means hibernate or sleep. And powerPolicy.mach.DozeS4TimeoutAc doesn't match with the hibernate (S4) time, is something like hibernationTime minus sleepTime.

So, for example, if I set manually sleep time to 8 minutes and hibernate to 1 minutes, I get IdleTimeoutAc equals 8 and DozeS4TimeoutAc 1. But, if I set sleep to 8 minutes and hibernate to 9, I get exactly the same result, so I cannot get the real value.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900