Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows - CPU power management APIs

What APIs are provided by Windows for CPU power management (I'm interested in CPU frequency scaling, setting min and max CPU frequency - similar to what you can do in Control Panel in power plans, but in a programmatic way). I'm also interested in .Net APIs. (It is not something I intend to use in a production environment, but rather as a proof of concept for some dynamic power management algorithms)

like image 681
kjv Avatar asked Mar 15 '10 22:03

kjv


2 Answers

The C++ Power Management APIs: http://msdn.microsoft.com/en-us/library/aa373170.aspx

.NET Power Management APIs are in the Microsoft.Win32 namespace.

Example from http://msdn.microsoft.com/en-us/library/hxkc1kwd.aspx:

private void powerModeChanged(System.Object sender, Microsoft.Win32.PowerModeChangedEventArgs e)
{
    int si = SystemInformation.PowerStatus;
    switch (si)
    {
        case BatteryChargeStatus.Low:
            MessageBox.Show("Battery is running low", MessageBoxIcon.Exclamation);
        case BatteryChargeStatus.Low:
            MessageBox.Show("Battery is critically low", MessageBoxIcon.Stop);
        Default:
            // Battery is okay.
    }
}

You can find lots more by poking around in that namespace.

like image 51
Dinah Avatar answered Sep 19 '22 07:09

Dinah


Have you tried digging in the power-management API ?

like image 38
shoosh Avatar answered Sep 18 '22 07:09

shoosh