How can I monitor my iPhone's charging status while plugged into my PC? -


i'm working on program monitors iphone's charging statues while plugged pc. how can in either vb, bat or c++?

you can set following on timer (in objc):

-(nsstring *)getbatterypercent {     cftyperef blob = iopscopypowersourcesinfo();     cfarrayref sources = iopscopypowersourceslist(blob);      cfdictionaryref psource = null;     const void *psvalue;      int i;     int curcapacity = 0;     int maxcapacity = 0;     int percent = 0;      int numofsources = cfarraygetcount(sources);     //if (numofsources == 0) return 1;      (i = 0 ; < numofsources ; i++)     {         psource = iopsgetpowersourcedescription(blob, cfarraygetvalueatindex(sources, i));          psvalue = (cfstringref)cfdictionarygetvalue(psource, cfstr(kiopsnamekey));          psvalue = cfdictionarygetvalue(psource, cfstr(kiopscurrentcapacitykey));         cfnumbergetvalue((cfnumberref)psvalue, kcfnumbersint32type, &curcapacity);          psvalue = cfdictionarygetvalue(psource, cfstr(kiopsmaxcapacitykey));         cfnumbergetvalue((cfnumberref)psvalue, kcfnumbersint32type, &maxcapacity);          percent = (int)((double)curcapacity/(double)maxcapacity * 100);     }     return [nsstring stringwithformat:@"%d",percent]; } 

to state of battery:

-(nsstring*)batterystatestatus:(uidevicebatterystate)state {     switch ( state )     {         case uidevicebatterystateunknown:             return @"unknown";             break;         case uidevicebatterystateunplugged:             return @"unplugged";             break;         case uidevicebatterystatecharging:             return @"charging";             break;         case uidevicebatterystatefull:             return @"charged";             break;     }      return nil; } 

edit:

requires iokit.framework

#include <iokit/iokitlib.h> #include <iokit/ps/iopowersources.h> #include <iokit/ps/iopskeys.h> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -