Re: Battery Check



Hi Liz

Thanks it work as I needed it to. Even not your best code it still work.

Petrus

"Liz" <liz_wants_no_spam@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:xn0faf0e3211lq400f@xxxxxxxxxxxxxxxxxxxxxxxxx
Petrus van Breda wrote:

I want to be able to check if the user is running on battery power
and not AC, when it reached a certain level on battery I want to know
as the application need to shut down. Does anybody know of such
components?

Back in 2000 I wrote an app that did that, it uses an API.. do I have
it ?? probably, can I find it? doesnt seem like it.

You are a lucky man!

procedure Tform1.updatescreen;
var status : Tsystempowerstatus;
begin
getsystempowerstatus(status);
if status.aclinestatus=1 then label1.caption:='AC Connected'
else label1.caption:='AC NOT Connected';
case status.batteryflag of
BATTERY_FLAG_HIGH : label2.caption:='High';
BATTERY_FLAG_LOW : label2.caption:='Low';
BATTERY_FLAG_CRITICAL : label2.caption:='Critical';
BATTERY_FLAG_CHARGING : label2.caption:='Charging';
BATTERY_FLAG_NO_BATTERY : label2.caption:='No battery';
BATTERY_FLAG_UNKNOWN : label2.caption:='Unknown';
else
label2.caption:='Charging';
end;
label3.caption:=inttostr(status.batterylifepercent)+'%';
if status.batterylifetime=BATTERY_LIFE_UNKNOWN then
label4.caption:='Unknown' else
label4.caption:=formatdatetime('dd
hh:mm:ss',status.batterylifetime);
if status.batteryfulllifetime=BATTERY_LIFE_UNKNOWN then
label5.caption:='Unknown' else
label5.caption:=formatdatetime('dd
hh:mm:ss',status.batteryfulllifetime);
end;

Not my best code, but I was very very very very ill at the time...

--
Liz the Brit
Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings


.



Relevant Pages

  • Re: Overall D2006 is MUCH better, but....
    ... in fastmm support! ... Liz the Brit ... Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings ...
    (borland.public.delphi.non-technical)
  • Re: Tried Out Delphi 2006
    ... without answering questions. ... Liz the Brit ... Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings ...
    (borland.public.delphi.non-technical)
  • Re: Delphi 2006 books...
    ... Liz the Brit ... Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings ...
    (borland.public.delphi.non-technical)
  • Re: BDS 2006 - Extending Live Code Templates
    ... somehow the upload did not work the first time:/ ... Liz the Brit ... Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings ...
    (borland.public.delphi.non-technical)
  • Re: Delphi interview questions
    ... They blend in perfectly with code I ... Liz the Brit ... Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings ...
    (borland.public.delphi.non-technical)