Mega Code Archive

 
Categories / Delphi / System
 

Get the power status

Title: get the power status? procedure TForm1.Button1Click(Sender: TObject); var SysPowerStatus: TSystemPowerStatus; begin GetSystemPowerStatus(SysPowerStatus); if Boolean(SysPowerStatus.ACLineStatus) then begin ShowMessage('System running on AC.'); end else begin ShowMessage('System running on battery.'); ShowMessage(Format('Battery power left: %d percent.', [SysPowerStatus.BatteryLifePercent])); end; end;