delphi – 如何检测笔记本电脑是否在运行电池?
发布时间:2020-12-15 04:27:48 所属栏目:大数据 来源:网络整理
导读:当笔记本电脑运行在电池(或AC)上时,如何检测(从德尔福)? 解决方法 要在Vista和 Windows 7上的状态更改时通知您,您可以使用 RegisterPowerSettingNotification . 对于Windows 2000及更高版本,请查看 GetSystemPowerStatus ,或转到MSDN阅读约Power Management
当笔记本电脑运行在电池(或AC)上时,如何检测(从德尔福)?
解决方法
要在Vista和
Windows 7上的状态更改时通知您,您可以使用
RegisterPowerSettingNotification .
对于Windows 2000及更高版本,请查看 (有人总是在我打字时发帖:-() function GetBattery : Boolean; var SysPowerStatus: TSystemPowerStatus; begin Win32Check(GetSystemPowerStatus(SysPowerStatus)); case SysPowerStatus.ACLineStatus of 0: Result := False; 1: begin Result := True; // You can return life with // String := Format('Battery power left: %u percent.',SysPowerStatus.BatteryLifePercent]); end; else raise Exception.Create('Unknown battery status'); end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |