Re: Battery Check
- From: "Petrus van Breda" <no.spam@xxxxxxxxxx>
- Date: Sun, 26 Aug 2007 20:41:36 +0200
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
.
- Follow-Ups:
- Re: Battery Check
- From: Liz
- Re: Battery Check
- References:
- Battery Check
- From: Petrus van Breda
- Re: Battery Check
- From: Liz
- Battery Check
- Prev by Date: Re: Battery Check
- Next by Date: Re: Battery Check
- Previous by thread: Re: Battery Check
- Next by thread: Re: Battery Check
- Index(es):
Relevant Pages
|
|