如何计算电池充满电的预计时间

来源:互联网 发布:知其数下一句是什么 编辑:程序博客网 时间:2024/06/02 07:49

//获取系统电池的充电速率,可以通过充电速率估算出电池充满的时间

#include <windows.h>#include <stdio.h>#include <winioctl.h>#include <intrin.h>#include <PowrProf.h>#pragma comment(lib,"PowrProf.lib") int _tmain(int argc, _TCHAR* argv[]){NTSTATUS Processor_information;SYSTEM_BATTERY_STATE p;Processor_information = CallNtPowerInformation(SystemBatteryState, NULL, 0, &p, sizeof(p));if (Processor_information == 0){ //STATUS_SUCCESSprintf("sucess \n");}else{printf("failure \n");}printf("AcOnLine: %d\n", p.AcOnLine);printf("BatteryPresent:  %d\n", p.BatteryPresent);printf("Charging:  %d\n", p.Charging);printf("MaxCapacity:  %d\n", p.MaxCapacity);printf("RemainingCapacity:  %d\n", p.RemainingCapacity);printf("Rate:  %d\n", p.Rate);printf("EstimatedTime:  %d\n", p.EstimatedTime);system("pause");return 0;}

上面输出了是否接通电源、电池剩余百分比电量、是否在充电、最大容量、剩余容量、充电速率,估计剩余时间等信息,

但是没有预计充满电的时间,但是可通过需要充电容量和充电速率计算剩余的充满时间。

1 0
原创粉丝点击