I try to encode a program that receives% of the laptop battery and then displays a CMD showing a message (for example: 10% β "Low battery!"). I tried to do this and it seems like they all tried with C ++ or C #. Can someone help me with C, please?
Edit: thanks zakinster for your answer. Shouldn't it look like this? This code does not work.
#include <Windows.h>
#include <Winbase.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
SYSTEM_POWER_STATUS status;
GetSystemPowerStatus(&status);
unsigned char battery = status.BatteryLifePercent;
printf("%s", battery);
}
source
share