windows 如何以编程方式停止笔记本电池充电
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1091775/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I programmatically stop a notebook battery from charging
提问by Marcel
There is some easily available information on finding the status of a battery, or weather it's charging or not. (GetSystemPowerStatus API or System.Windows.Forms.SystemInformation.PowerStatus).
有一些关于查找电池状态或天气是否正在充电的容易获得的信息。(GetSystemPowerStatus API 或 System.Windows.Forms.SystemInformation.PowerStatus)。
I want to be able to stop a battery from charging based on some criteria, e.g. battery power > 20%.
我希望能够根据某些标准停止电池充电,例如电池电量 > 20%。
Is there an API to do this?
有没有 API 可以做到这一点?
采纳答案by MicTech
I think it's impossible, because you have need some API for battery or battery charger.
我认为这是不可能的,因为您需要一些用于电池或电池充电器的 API。
And this API can provide to you manufacturer of notebook and battery or battery charger support this.
而这个 API 可以为您的笔记本和电池制造商或电池充电器提供支持。
回答by Hyman Leow
I honestly don't know, but I'd have a look at the APMor ACPIAPIs.
Other than that, the only option I can think of right now is a USB controlled robotic arm that ejects the battery when you need to stop charging, but that's probably not what you are looking for, and borders on the complicator's glovein terms of level of over-engineering. :)
除此之外,我现在能想到的唯一选择是一个 USB 控制的机械臂,当你需要停止充电时它会弹出电池,但这可能不是你想要的,并且在水平方面接近复杂器的手套过度工程化。:)
回答by Matt
I think it's possible, because it was patented by IBM (patent no. 7570015).
我认为这是可能的,因为它是 IBM 的专利(专利号 7570015)。
Not sure if there's a Windows API available for that.
不确定是否有可用的 Windows API。
回答by TJ-
One of the options is to get hold of the device(I) for battery (Microsoft ACPI-Compliant Control Method Battery). Listen for PowerNotification events forever. On each notification check the PowerStatus of the battery. There are APIs for all of the above purposes in .Net and win32
选项之一是获取设备(I)的电池(Microsoft ACPI-Compliant Control Method Battery)。永远监听 PowerNotification 事件。在每个通知中检查电池的 PowerStatus。在 .Net 和 win32 中有用于上述所有目的的 API
Keep the device(I) disabled as long as the powerstatus is >threshold. Enable it as soon as goes below that or when you are not on AC power (i.e. before removing AC power, your continuously monitoring software should enable that battery device - or you manually enable it).
只要 powerstatus 大于阈值,就保持设备 (I) 处于禁用状态。一旦低于该值或当您没有使用交流电源时(即在移除交流电源之前,您的持续监控软件应启用该电池设备 - 或者您手动启用它),请立即启用它。
hmm,...this is a very buggy solution, but it can achieve what you want, although you have to be very careful.
嗯,...这是一个非常有问题的解决方案,但它可以实现您想要的,尽管您必须非常小心。
回答by Oskar Duveborn
I would just get a UPS and programatically tell it to cut all power... most should have an interface for doing this. Otherwise, as someone already said - a computer-controlled power strip would do it ^^
我只会得到一个 UPS 并以编程方式告诉它切断所有电源......大多数应该有一个界面来做到这一点。否则,正如有人已经说过的那样 - 计算机控制的电源板可以做到 ^^
I've actually played with this idea when I was testing/writing about way too many new laptop models a while ago and the battery testing was annoying to set up, monitor and analyze.
不久前,当我测试/撰写太多新笔记本电脑型号时,我实际上已经考虑过这个想法,而电池测试的设置、监控和分析很烦人。
I wrote an app that would do exactly everything (setup, listening, measuring, reporting) except unplugging the power and then replugging it and starting the computer again...
我编写了一个应用程序,除了拔掉电源然后重新插入并再次启动计算机之外,它可以完成所有操作(设置、监听、测量、报告)...
回答by Shoban
I think MiCTech is right. I dont think it is possible but here are some resources which you might useful.
我认为 MiCTech 是对的。我不认为这是可能的,但这里有一些您可能有用的资源。
回答by Shoban
But for example Vista won't charge battery if it is unplugged and then plugged while it's capacity is above 96% so it means that in can be accessed and manipulated somehow.
但是例如,如果Vista在其容量超过96%时拔下然后再插入,则不会为电池充电,因此这意味着可以以某种方式访问和操作。
回答by Mario M
Lenovo laptops know lets you specify the charging levels from bios or from their software, but this feature must be implemented in bios in order to be accessed from windows.
联想笔记本电脑知道可以让您从 bios 或其软件中指定充电级别,但必须在 bios 中实现此功能才能从 windows 访问。
回答by T.Todua
I came to conclusion:
我得出结论:
just give up and forget this matter. It is not a problem, so dont worry about that. Let it be plugged in and be fully charged. when it is on 100%, then the system automatically stops charging, and goes on the plug power, so, maybe no worry to wear a battery, as all notebooks (if it's not from the XX century) has auto regulation of it. Although, If you will ever need, move you hands and plug it on/off manually. Dont be lazy. That is the #1 and quickest solution, beleive me.
就放弃吧,忘记这件事。这不是问题,所以不用担心。让它插入并充满电。当它处于 100% 时,系统会自动停止充电,并打开插头电源,因此,也许不用担心佩戴电池,因为所有笔记本电脑(如果不是 20 世纪的)都有自动调节功能。虽然,如果您需要,请移动您的手并手动打开/关闭它。不要偷懒。这是#1和最快的解决方案,相信我。
(however, if you want to waste time, here are methods -
1) http://www.makeuseof.com/answers/what-battery-manager-can-stop-charging-at-a-certain-percentage/
2) disable devices temporarily(But you need to disable "Microsoft ACPI-Compliant Control Method Battery")
3) https://superuser.com/questions/813182/how-to-stopdisable-battery-charging-on-laptop
(但是,如果你想浪费时间,这里有方法 -
1)http://www.makeuseof.com/answers/what-battery-manager-can-stop-charge-at-a-certain-percentage/
2)暂时禁用设备(但您需要禁用“ Microsoft ACPI-Compliant Control Method Battery”)
3) https://superuser.com/questions/813182/how-to-stopdisable-battery-charge-on-laptop