Re: Battery Check



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: Battery Check
    ... when it reached a certain level on battery I want to know ... Liz the Brit ... Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Battery Check
    ... Petrus van Breda wrote: ... At the time I wrote it I had been told I would most certainly die ... Liz the Brit ... Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: {$define} lazarus / delphi
    ... that in order to know if the compiler is Delphi or Free Pascal (Lazarus) ... {$ifdef FPC} ... or a battery of for each of the different ... Delphi versions. ...
    (comp.lang.pascal.misc)