gpt4 book ai didi

macos - 如何确定 OSX 是否使用电池而非电源

转载 作者:行者123 更新时间:2023-12-03 16:11:02 25 4
gpt4 key购买 nike

我想在电池模式下调整应用程序的功能

当模式改变时如何检测应用程序是否处于电池模式等?

最佳答案

IOPSGetTimeRemainingEstimate function返回剩余电量。

引自讨论部分:

If attached to an "Unlimited" power source, like AC power or any external source, the return value is kIOPSTimeRemainingUnlimited

If the system is on "Limited" power, like a battery or UPS, but is still calculating the time remaining, which may take several seconds after each system power event (e.g. waking from sleep, or unplugging AC Power), the return value is kIOPSTimeRemainingUnknown

Otherwise, if the system is on "Limited" power and the system has an accurate time remaining estimate, the system returns a CFTimeInterval estimate of the time remaining until the system is out of battery power.

If you require more detailed battery information, use IOPSCopyPowerSourcesInfo> and IOPSGetPowerSourceDescription>.

<小时/>

IOPSNotificationCreateRunLoopSource function可用于注册电源相关事件的回调函数。

关于macos - 如何确定 OSX 是否使用电池而非电源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24733503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com