To access the Windows system's current power state (battery level, ac present etc.) from my C++ application, I'm currently using the following WinAPI function:
BOOL WINAPI GetSystemPowerStatus(_Out_ LPSYSTEM_POWER_STATUS lpSystemPowerStatus);
This works well but the results I get with this call are too "old". Maybe this is because Windows or the connected UPS do update these values not that often.
Does anyone know a workaround for this? Or does anyone have a different solution for polling the system's current power state which may deliver more recent results?
Edit: I need this information to inform/warn the user about the power situation (fullscreen app, no Windows shell) and to transfer my application/device into a safe state when the battery level of the UPS gets critical in case of an AC power failure.