PSP Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Welcome, Guest
You last visited:


You are not connected. Please login or register

Battery Life support snippet - C++

2 posters

Go down  Message [Page 1 of 1]

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

Blacksun

Blacksun
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;
}

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

sunsucker

sunsucker
Top Member
Top Member

thx for posting

Back to top  Message [Page 1 of 1]

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