简体   繁体   English

在Windows中以编程方式确定电源使用情况?

[英]Determine power usage programmatically in Windows?

Are there any OS capabilities in Windows to know your system's current power usage programmatically? Windows中是否有任何操作系统功能可以通过编程方式了解系统当前的电源使用情况? (Ideal solution could be via WMI interface.) (理想的解决方案可以通过WMI接口。)

从Windows 7开始,您可以使用位于root\\CIMV2\\power命名空间中的Win32_PowerMeter WMI类,此命名空间包含许多与电源管理和配置文件相关的其他类和事件。

I don't know of anything on an instantaneous basis, but GetSystemPowerStatus can give an estimate of remaining battery power. 我暂时不知道任何事情,但GetSystemPowerStatus可以估算剩余电池电量。 Calling that every few minutes (or something on that order) would give an idea of how quickly you're using power, at least as a percentage of the battery life. 每隔几分钟(或该订单上的某些内容)调用就会知道您使用电源的速度,至少占电池寿命的百分比。 Of course, that really only works when/if there is a battery -- on a desktop or server system it normally won't produce anything useful. 当然,这实际上只有在有电池时才有效 - 在台式机或服务器系统上它通常不会产生任何有用的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM