Private Declare Function GetSystemPowerStatus Lib "kernel32" _ (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As LongPrivate Type SYSTEM_POWER_STATUS ACLineStatus As Byte BatteryFlag As Byte BatteryLifePercent As Byte Reserved1 As Byte BatteryLifeTime As Long BatteryFullLifeTime As LongEnd Type' Get the life time of a notebook's battery.' Returns -1 if the computer is not a notebook or if it's not using a battery' Param values:' 0 -> return the lifetime in seconds (by default)' 1 -> return the lifetime in minutes' 2 -> return the lifetime in hours' Example:' MsgBox "Left minutes:" & GetBatteryTime(1)Private Function GetBatteryTime(Optional ByVal ResultFormat As Integer) As _ Double Dim SysStatus As SYSTEM_POWER_STATUS GetSystemPowerStatus SysStatus ' return the number of seconds If ResultFormat = 0 Then GetBatteryTime = SysStatus.BatteryLifeTime ' return the number of minutes ElseIf ResultFormat = 1 Then GetBatteryTime = SysStatus.BatteryLifeTime / 60 ' return the number of hours Else GetBatteryTime = SysStatus.BatteryLifeTime / 3600 End IfEnd Function


Top Web Development Companies in India
In the digital race, the right web development partner is your winning edge. Dive into our curated list of top web development companies in India,