Battery_Module
Amjad Moustafa :: VB6 :: Modules
صفحة 1 من اصل 1
Battery_Module
Private Type SYSTEM_POWER_STATUS
ACLineStatus As Byte
BatteryFlag As Byte
BatteryLifePercent As Byte
Reserved1 As Byte
BatteryLifeTime As Long
BatteryFullLifeTime As Long
End Type
Private Declare Function GetSystemPowerStatus Lib "kernel32" (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As Long
Function Adapter_State() As String
Dim SPS As SYSTEM_POWER_STATUS
'get the battery powerstatus
GetSystemPowerStatus SPS
'
Select Case SPS.ACLineStatus
Case 0
Adapter_State2 = "Adapter Offline"
Case 1
Adapter_State2 = "Adapter Online"
Case 2
Adapter_State2 = "Unknown Adapter State "
End Select
End Function
Function Battery_State() As String
Dim SPS As SYSTEM_POWER_STATUS
'get the battery powerstatus
GetSystemPowerStatus SPS
'
Select Case SPS.BatteryFlag
Case 1
Battery_State2 = "High Battery"
Case 2
Battery_State2 = "Low Battery"
Case 4
Battery_State2 = "Very Low Battery"
Case 8
Battery_State2 = "Charging"
Case 9
Battery_State2 = "Charging"
Case 128
Battery_State2 = "No Battery"
Case 255
Battery_State2 = "Unknown Battery State"
End Select
If SPS.BatteryFlag > 9 And SPS.BatteryFlag < 128 Then Battery_State2 = "Charging"
'Battery_State = SPS.BatteryFlag
End Function
Function Battery_Percent() As String
Dim SPS As SYSTEM_POWER_STATUS
'get the battery powerstatus
GetSystemPowerStatus SPS
'
Battery_Percent = SPS.BatteryLifePercent
End Function
Function Battery_Life() As String
Dim SPS As SYSTEM_POWER_STATUS
'get the battery powerstatus
GetSystemPowerStatus SPS
'
Battery_Life = SPS.BatteryLifeTime \ 3600 & " hour " & Round((SPS.BatteryLifeTime / 3600 - SPS.BatteryLifeTime \ 3600) * 60, 0) & " minute"
End Function
Amjad Moustafa :: VB6 :: Modules
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى