VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Find out whether or not a laptop is running on battery power and if so how much battery time is rem

by Roderick Thompson (12 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 1st April 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Find out whether or not a laptop is running on battery power and if so how much battery time is remaining.

API Declarations


Public Type SYSTEM_POWER_STATUS
ACLineStatus As Byte
BatteryFlag As Byte
BatteryLifePercent As Byte
Reserved1 As Byte
BatteryLifeTime As Long
BatteryFullLifeTime As Long
End Type


Rate Find out whether or not a laptop is running on battery power and if so how much battery time is rem




Dim SysStatus As SYSTEM_POWER_STATUS, LifeTime As Double
GetSystemPowerStatus SysStatus
LifeTime = SysStatus.BatteryLifeTime
If LifeTime = -1 Then
    MsgBox "Using AC Power"
Else
    MsgBox LifeTime / 3600 & " hours remaining"
End If

End Sub

Download this snippet    Add to My Saved Code

Find out whether or not a laptop is running on battery power and if so how much battery time is rem Comments

No comments have been posted about Find out whether or not a laptop is running on battery power and if so how much battery time is rem. Why not be the first to post a comment about Find out whether or not a laptop is running on battery power and if so how much battery time is rem.

Post your comment

Subject:
Message:
0/1000 characters