Is it possible to write in C to get the alert. If yes, what is the concept to be applied to get an alert when my battery goes down by 40% or gets high to 80%?
Asked
Active
Viewed 127 times
1
-
3It depends on the OS you're running on. For a gist on how to do this on Windows check this one out: https://stackoverflow.com/questions/233446/monitor-battery-charge-with-win32-api – amdmax Jun 20 '17 at 08:41
-
Your OS might contain an appropriate API for this. If one of the newer Windows, then the "check this one out" above will help. – Bathsheba Jun 20 '17 at 08:41
-
1The simplest answer might be that your laptop probably already has a program that does this. – Neil Jun 20 '17 at 08:50
1 Answers
1
You have to use Windows API to get the battery information. Please refer to the link: https://msdn.microsoft.com/en-us/library/windows/desktop/aa372659(v=vs.85).aspx
The following ioctls are used to get the battery information
IOCTL_BATTERY_QUERY_INFORMATION
IOCTL_BATTERY_QUERY_STATUS
IOCTL_BATTERY_QUERY_TAG
IOCTL_BATTERY_SET_INFORMATION
GetSystemPowerStatus
function is used to get the power status in windows. Refer to the link: https://msdn.microsoft.com/en-us/library/windows/desktop/aa372693(v=vs.85).aspx

Community
- 1
- 1

Rajeshkumar
- 739
- 5
- 16