【发布时间】:2013-05-05 01:00:17
【问题描述】:
我正在寻找当前的电池容量和设计容量。
到目前为止,我可以使用Win32_Battery() class,它没有提供我需要的所有信息(至少在我的系统上没有)。为此,我使用了纯 python wmi library。
另一方面,我发现它可以工作 In Python, how can I detect whether the computer is on battery power?,但不幸的是它也没有提供任何有关容量的信息。
Battery Information structure 和 Battery Status structure 似乎很适合这个。现在我知道我必须使用DeviceIoControl function 这样做,我发现这个C++ code 解释了一点。
我更喜欢只使用 ctypes 而不是 pywin32 提供的 python win32api 的东西。 如果您知道如何在 python 中执行此操作,请告诉我!
提前致谢。
【问题讨论】:
-
我假设您不想使用
win32api,因为您想在其他平台上使用代码,所以我不确定其他方法可以做到这一点,因为所有系统都有不同的 API。如果您不需要其他平台,我可以帮助您 -
我的代码适用于 linux 和 mac os。我现在正在尝试为 Windows 获取一些东西,pywin32、win32api 就可以了。我最初只是想避免有外部库需求。
标签: python windows ctypes pywin32 battery