简体   繁体   中英

Determine power usage programmatically in Windows?

Are there any OS capabilities in Windows to know your system's current power usage programmatically? (Ideal solution could be via WMI interface.)

从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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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