Can somebody please help me with the c code for monitoring System power,that is how to check if a pc or laptop is running on power or battery

Recommended Answers

All 3 Replies

I don't know about Windows (or Mac OS...), but if the machine is running Linux, there should be something in /proc that can help you. On my laptop (running Arch Linux) the files state and info in /proc/acpi/battery/BAT1 had pretty much all the information about the battery, including whether or not it's discharging, the power consumption, power remaining, etc. Just read these files and parse them for the information you want.

thanks,will try that

Thank you orwell84 managed to use the information you gave me to have proper code for what i was looking for,but i was using java, thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.