![]() |
Status der System-batterie ermitteln
Delphi-Quellcode:
Nico Bendlin (NicoDE), Michael Puff (Luckie)
function GetPowerStatus(var HasBattery: Boolean; var LoadStatusString: String;
var LoadstatusPercent: Integer): DWORD; var SystemPowerStatus: TSystemPowerStatus; Text: string; resourcestring rsLoadStatusUnknown = 'Unbekannter Status'; rsLoadStatusNoBattery = 'Es existiert keine Batterie'; rsLoadStatusHigh = 'Hoher Ladezustand'; rsLoadStatusLow = 'Niedriger Ladezustand'; rsLoadStatusCritical = 'Kritischer Ladezustand'; rsLoadStatusLoading = 'Batterie wird geladen'; rsLoadSatusUnknownLoading = 'Unbekannter Ladezustand'; begin SetLastError(0); if GetSystemPowerStatus(SystemPowerStatus) then with SystemPowerStatus do begin HasBattery := ACLineStatus = 0; // Ladezustand der Batterie if (BatteryFlag = 255) then Text := rsLoadStatusUnknown else if (BatteryFlag and 128 = 128) then Text := rsLoadStatusNoBattery else begin case (BatteryFlag and (1 or 2 or 4)) of 1: Text := rsLoadStatusHigh; 2: Text := rsLoadStatusLow; 4: Text := rsLoadStatusCritical; else Text := rsLoadSatusUnknownLoading end; if (BatteryFlag and 8 = 8) then LoadStatusString := Text + rsLoadStatusLoading; end; // Ladezustand in Prozent if (BatteryLifePercent <> 255) then LoadstatusPercent := BatteryLifePercent else LoadstatusPercent := -1; end; Result := GetLastError; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:11 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz