May 1, 2010 08:58 PM
(This post was last modified: May 2, 2010 02:12 PM by codepoet.)
originally posted on dotnet-snippets.com
Description:
With this little class you can check the battery status of your notebook.
If You Like this tutorial, please check out my other tutorials by clicking ==> H3R3
Description:
With this little class you can check the battery status of your notebook.
Code
Public Class BatteryStatus
Private Declare Auto Function GetSystemPowerStatus Lib "kernel32.dll" ( _
ByRef lpSystemPowerStatus As SYSTEM_POWER_STATUS) _
As Integer
Public Structure SYSTEM_POWER_STATUS
Public ACLineStatus As ACLineStatus
Public BatteryFlag As BatteryFlag
Public BatteryLifePercent As Byte
Public Reserved1 As Byte
Public BatteryLifeTime As Integer
Public BatteryFullLifeTime As Integer
End Structure
Public Enum BatteryFlag As Byte
High = 1
Low = 2
Critical = 4
Charging = 8
NoSystemBattery = 128
Unknown = 255
End Enum
Public Enum ACLineStatus As Byte
Offline = 0
Online = 1
Unknown = 255
End Enum
Public Shared Function GetStatus() As SYSTEM_POWER_STATUS
Dim SPS As New SYSTEM_POWER_STATUS
GetSystemPowerStatus(SPS)
Return SPS
End Function
End ClassIf You Like this tutorial, please check out my other tutorials by clicking ==> H3R3
PHP & .NET Contributor.


