I am currently working on an app to automatically turn off my computer when battery reaches 8%. I just started a couple minutes ago, and came across some working code to retrieve the percent of battery life. Note I have more experience in C# and just starting C++, so calling unmanaged code from unmanaged code is new to me. Does anyone know where a good reference is? And specifically does MSN have a worthwhile one? Basically like the C++ equivalent to the lists of functions you can import from user32.dll in C#.
CODE
#include <windows.h>
#include <iostream>
#define UNKNOWN 0xFFFFFFFF
using namespace std;
int main(void)
{
SYSTEM_POWER_STATUS status;
GetSystemPowerStatus( &status );
int life = status.BatteryLifePercent;
int secs = status.BatteryLifeTime;
cout << "Life is " << life << "%" << endl;
cin.ignore(cin.rdbuf()->in_avail() + 1);
return 0;
}
I know I shouldn't use the entire namespace at once, I'll work on speed once I actually get it working =P Note I'm quite sure I can finish my app, I'm just curious for a reference. Sorry for any confusion.
This post has been edited by PassionFRUI7E: 5 Oct, 2008 - 03:44 PM