...get the power status?

Author: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch

Category: System

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;

 

printed from
www.swissdelphicenter.ch
developers knowledge base