Reputation:
I'm trying to figure out, how to get Event of Power Plan Changing between High Performance, Power Saver and Balanced, I need it to change my app with different mode for each plan. I found some solutions on this direction, but does not get desired result.
For example if I take item.CurrentMhz
, which registers processor current power value, it is useful for different purposes, but this outputs does not gives me Power Plan state public uint Number; MaxMhz; CurrentMhz; MhzLimit; MaxIdleState; CurrentIdleState;
. For example CurrentIdleState
is equal on Power Saver and High Performance plan. Anyway if I can somehow use it, main problem is that I can't make it work as event, only as conditional result. But as fact it is not the Power Plan State, and power value is different for different processors. Seems like for this goal it is not the correct way to get desired result.
SystemEvents_PowerModeChanged
also does not make sense for this case, takes only Power State changing event if cord is connected or disconnected.
Same with PowerStatus powerStatus = SystemInformation.PowerStatus;
which is same, but with identification of Current Power Status if cord is connected or disconnected.
So I'm not sure, if there is any useful solution, how can I get this event between Power Plans changing.
Upvotes: 1
Views: 651
Reputation: 14038
There are more than just those three plans. From Control Panel you can edit plans and create new plans. So do not expect to find a three-valued enum
.
The PBT_APMPOWERSTATUSCHANGE
event indicates changes in power states. That page then says to read the SYSTEM_POWER_POLICY
structure which contain the settings controlled by power plans.
So the approach would seem to be to handle the PBT_APMPOWERSTATUSCHANGE
event, call GetSystemPowerStatus
to get the current power status in a SYSTEM_POWER_POLICY
structure and then pick out the values that are important to your application.
Upvotes: 1