Mega Code Archive

 
Categories / Delphi / Hardware
 

Get power status

Title: Get power status Use GetSystemPowerStatus function and SYSTEM_POWER_STATUS structure. procedure TForm1.Button1Click(Sender: TObject); var PowerStatus: TSystemPowerStatus; begin GetSystemPowerStatus(PowerStatus); if PowerStatus.ACLineStatus=1 then Label1.Caption:='AC power online' else Label1.Caption:='AC power offline'; end;