vc++如何获取笔记本电源电量信息以及充电状态
2017-06-26 17:30
423 查看
http://bbs.csdn.net/topics/391051005
从论坛摘抄
GetSystemPowerStatus 获取电池总容量跟剩余容量的API函数
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
从论坛摘抄
GetSystemPowerStatus 获取电池总容量跟剩余容量的API函数
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
相关文章推荐
- 获取当前手机的电池充电状态以及当前的电量
- WP8开发系列2:如何获取设备电源信息?电量
- 如何获取搜索引擎的来源,以及搜索引擎的相关信息
- 关闭主窗体而不退出主程序 以及如何获取操作系统的关闭、注销信息
- VC如何获取QQ好友发来的信息
- linux下的shell命令的编写,以及java如何调用linux的shell命令(java如何获取linux上的网卡的ip信息)
- [100分求助]如何使用VC编程获取网卡当前的状态 - IT者
- 如何获取iphone的硬件版本以及系统信息
- vc++调用exe时,如何获取exe的输出信息
- iPhone应用中如何获取硬件版本以及系统信息
- VC如何获取QQ好友发来的信息
- 如何获取iPhone电池的状态和当前的电量
- AS/400开发经验点滴(四)如何在程序中获取系统ASP使用率等系统状态信息
- 如何获取iphone的硬件版本以及系统信息
- WinAPI: GetSystemPowerStatus - 获取系统电源状态的信息
- 关闭主窗体而不退出主程序 以及如何获取操作系统的关闭、注销信息
- 如何获取iphone的硬件版本以及系统信息
- Best Practices for Performance_4.Optimizing Battery Life 获取充电状态、电池信息,"sticky"类型的广播
- UIDevice获取设备数据以及如何获取应用信息
- VC++ 中 try-catch-finally 语句 如何在获取正常信息是写一些操作语句