-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBattery.cpp
52 lines (45 loc) · 1.2 KB
/
Battery.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* \file Battery.cpp
* \brief
*/
#include <windows.h>
#include <iostream>
//-------------------------------------------------------------------------------------------------
#define UNKNOWN \
0xFFFFFFFF
//-------------------------------------------------------------------------------------------------
using namespace std;
int main()
{
SYSTEM_POWER_STATUS status;
GetSystemPowerStatus(&status);
int life = status.BatteryLifePercent;
int secs = status.BatteryLifeTime;
cout << life << "% -> ";
switch (status.BatteryFlag) {
case 1:
cout << "High";
break;
case 2:
cout << "Low";
break;
case 4:
cout << "Critical";
break;
case 8:
cout << "Charging";
break;
case 128:
cout << "No system battery";
break;
case 256:
cout << "Unknown status";
break;
}
if (secs == UNKNOWN) {
cout << endl << "Amount of time remaining is unkown";
} else {
cout << endl << secs << " seconds remaining";
}
}
//-------------------------------------------------------------------------------------------------