VB.net 电池寿命百分比

VB.net battery life percentage

我尝试了很多方法试图制作一个显示电池百分比的小程序(该值显示在进度条上)。有人可以帮助我吗?

Dim power As SystemInformation.PowerStatus = SystemInformation.PowerStatus
Dim percent As Single = power.BatteryLifePercent    

' Display the ProgressBar control.
    pBar1.Visible = true;

' Set min and max
    pBar1.Minimum = 0
    pBar1.Maximum = 100

' Set the current value 
    pBar1.Value = percent * 100

然后你只需要用定时器或其他东西刷新。