How to detect battery status? lazarus / 34-Windows ---------------------------------------------------------------------- Marion · 2012-04-23 20:44 My app needs to be able to tell how much battery life is left and if it is charging. Does anyone have an code sample for this? ---------------------------------------------------------------------- ludob · 2012-04-24 06:40 What system are you using? Your avatar is not clear. It could be interpreted as a "programmer recovering from windows programming"  If you are still on windows you can use the following code (timer updating label1): Code: [Select]uses ...windows; ... procedure TForm1.Timer1Timer(Sender: TObject); var   PowerStatus:TSystemPowerStatus; begin   if GetSystemPowerStatus(PowerStatus) then     begin     if (PowerStatus.BatteryFlag and 8) <>0 then       label1.Caption:='Charging'     else       label1.Caption:=IntToStr(PowerStatus.BatteryLifePercent) +'% ( '+         IntToStr(PowerStatus.BatteryLifeTime div 60) +' mins left )';     end; end; ---------------------------------------------------------------------- Marion · 2012-04-24 10:10 Thank you for the reply. This is exactly what I need. As for recovering from windows programming I fell off the wagon. I took a job last week that will be mostly windows. I will get to program for android. After over a year unemployed I am just greatful for a job.