Share via

What is the recommended approach for checking low battery events in Windows?

Rohan Pande 445 Reputation points
2024-05-29T06:22:42.56+00:00

Hi,

I am developing an application and need to register for a low-battery event in Windows. I have reviewed the PowerSettingGUIDs documentation and found a value named GUID_POWER_SAVING_STATUS.

Reference: https://learn.microsoft.com/en-us/windows/win32/power/power-setting-guids

However, this value is also set to true when the user manually turns on battery saver. What is the recommended approach for checking low battery events?

Windows development | Windows API - Win32
0 comments No comments
{count} votes

Answer accepted by question author
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2024-05-29T07:38:00.92+00:00

    Hello,

    Welcome to Microsoft Q&A!

    You could try to use GetSystemPowerStatus function to retrieve the current power status of the computer. In particular, the application should check the BatteryFlag, BatteryLifeTime, and BatteryLifePercent members of the SYSTEM_POWER_STATUS structure for any changes. PBT_APMPOWERSTATUSCHANGE eventcan occur when battery life drops to less than 5 minutes, or when the percentage of battery life drops below 10 percent, or if the battery life changes by 3 percent.

    For more details you could refer to the Doc: System Power Status Events

    Thank you.

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.