Find out battery charge capacity in percentage using C# or .NET

后端 未结 9 1502
谎友^
谎友^ 2020-12-03 03:21

I have an application that gets detailed system information, and I have been able to get the percent of charge remaining but not the percent of the battery itself.

E

9条回答
  •  伪装坚强ぢ
    2020-12-03 03:43

    No need to unnecessary complicate things. Try something like:

    using System.Management;
    
    PowerStatus pwr = SystemInformation.PowerStatus;
    
    String strBatteryChargingStatus;
    strBatteryChargingStatus = pwr.BatteryChargeStatus.ToString();
    MessageBox.Show("battery charge status : " + batterystatus);
    
    String strBatterylife;
    strBatterylife = pwr.BatteryLifePercent.ToString();
    MessageBox.Show("Battery life: "+batterylife);
    

    In this way you can get all of the battery information.

提交回复
热议问题