Pergunta

Estou tentando escrever um pequeno aplicativo que monitora quanta energia resta em uma bateria de notebooks e gostaria de saber qual função Win32 eu poderia usar para conseguir isso.

Foi útil?

Solução

For Vista and up you can use RegisterPowerSettingNotification

For earlier functions see the Power Management Functions in this section of the MSDN page "Power Management Functions: Windows Server 2003 and Earlier"

You can see example code of the Vista method on codeproject.

Outras dicas

I recommend the use of the Win32 GetSystemPowerStatus function. A code snippet :

int getBatteryLevel()
{
    SYSTEM_POWER_STATUS status;
    GetSystemPowerStatus(&status);
    return status.BatteryLifePercent;
}

There is a very detailed article in the following link, as well as a n example project (tested working on Win8.1): http://www.codeproject.com/Articles/15829/Vista-Goodies-in-C-Monitoring-the-Computer-s-Power

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top