Welcome, Guest
You last visited:


You are not connected. Please login or register

Battery Life support snippet - C++

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Battery Life support snippet - C++ on Sat Nov 06, 2010 7:12 am

Blacksun

avatar
GFX Team
GFX Team
#
/*
* Battery Life support
#
* Credits to _-_EVIL-LOCO_-_
#
* Dev C++
#
*/
#include
#include

#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;
case 300: cout << "Times up";
break;
case 360: cout << "Off mode";
break;
}

if (secs == UNKNOWN) {
cout << endl << "Amount of time remaining is unkown";
}
else cout << endl << secs << " seconds remaining";

Sleep( 2000 );
system("PAUSE");
return 0;
}


_________________
[You must be registered and logged in to see this image.]
View user profile

2 Re: Battery Life support snippet - C++ on Tue Nov 09, 2010 9:35 am

sunsucker

avatar
Top Member
Top Member
thx for posting

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum