vc++如何获取笔记本电源电量信息以及充电状态

SssQqq_ 2015-06-10 09:03:13
用VC++如何获取笔记本的电源电量信息,是否正在充电的状态?WINDOWS既然可以监控,信息应该是可以获取的吧,求大神,有源码更好
...全文
856 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
金河流域 2017-08-03
  • 打赏
  • 举报
回复
WIN 10系统 C++切断笔记本电源吗?
boylafong 2015-06-11
  • 打赏
  • 举报
回复
引用 3 楼 qq_28538381 的回复:
那有可以获取电池总容量跟剩余容量的API函数么?
不是发给你函数了吗 GetSystemPowerStatus
赵4老师 2015-06-11
  • 打赏
  • 举报
回复
GetSystemPowerStatus Function 发送反馈 Retrieves the power status of the system. The status indicates whether the system is running on AC or DC power, whether the battery is currently charging, and how much battery life remains. Syntax C++以带有颜色区分的格式查看复制到剪贴板打印BOOL WINAPI GetSystemPowerStatus( __out LPSYSTEM_POWER_STATUS lpSystemPowerStatus ); BOOL WINAPI GetSystemPowerStatus( __out LPSYSTEM_POWER_STATUS lpSystemPowerStatus ); Parameters lpSystemPowerStatus [out] A pointer to a SYSTEM_POWER_STATUS structure that receives status information. Return Value If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. Remarks To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0400 or later. For more information, see Using the Windows Headers. Requirements Minimum supported client Windows 2000 Professional Minimum supported server Windows 2000 Server Header Winbase.h (include Windows.h) Library Kernel32.lib DLL Kernel32.dll See Also System Power Status Power Management Functions SYSTEM_POWER_STATUS Send comments about this topic to Microsoft Build date: 12/13/2009 © 2011 Microsoft Corporation。保留所有权利 发送反馈 (请阅读我们的 Visual Studio 反馈策略) SYSTEM_POWER_STATUS Structure 发送反馈 Contains information about the power status of the system. Syntax C++以带有颜色区分的格式查看复制到剪贴板打印typedef struct _SYSTEM_POWER_STATUS { BYTE ACLineStatus; BYTE BatteryFlag; BYTE BatteryLifePercent; BYTE Reserved1; DWORD BatteryLifeTime; DWORD BatteryFullLifeTime; } SYSTEM_POWER_STATUS, *LPSYSTEM_POWER_STATUS; typedef struct _SYSTEM_POWER_STATUS { BYTE ACLineStatus; BYTE BatteryFlag; BYTE BatteryLifePercent; BYTE Reserved1; DWORD BatteryLifeTime; DWORD BatteryFullLifeTime; } SYSTEM_POWER_STATUS, *LPSYSTEM_POWER_STATUS; Members ACLineStatus The AC power status. This member can be one of the following values. Value Meaning 0 Offline 1 Online 255 Unknown status BatteryFlag The battery charge status. This member can contain one or more of the following flags. Value Meaning 1 High—the battery capacity is at more than 66 percent 2 Low—the battery capacity is at less than 33 percent 4 Critical—the battery capacity is at less than five percent 8 Charging 128 No system battery 255 Unknown status—unable to read the battery flag information The value is zero if the battery is not being charged and the battery capacity is between low and high. BatteryLifePercent The percentage of full battery charge remaining. This member can be a value in the range 0 to 100, or 255 if status is unknown. Reserved1 Reserved; must be zero. BatteryLifeTime The number of seconds of battery life remaining, or –1 if remaining seconds are unknown. BatteryFullLifeTime The number of seconds of battery life when at full charge, or –1 if full battery lifetime is unknown. Remarks The system is only capable of estimating BatteryFullLifeTime based on calculations on BatteryLifeTime and BatteryLifePercent. Without smart battery subsystems, this value may not be accurate enough to be useful. Requirements Minimum supported client Windows 2000 Professional Minimum supported server Windows 2000 Server Header Winbase.h (include Windows.h) See Also GetSystemPowerStatus PBT_APMPOWERSTATUSCHANGE Send comments about this topic to Microsoft Build date: 12/13/2009 © 2011 Microsoft Corporation。保留所有权利 发送反馈 (请阅读我们的 Visual Studio 反馈策略)
oyljerry 2015-06-10
  • 打赏
  • 举报
回复
通过WMI去查询
boylafong 2015-06-10
  • 打赏
  • 举报
回复
GetSystemPowerStatus
SssQqq_ 2015-06-10
  • 打赏
  • 举报
回复
那有可以获取电池总容量跟剩余容量的API函数么?

2,640

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧