Neal Hartman
asked on
GetSystemPowerStatus
Why do I get "Object reference not set to an instance of an object" when the API is called?
Public Structure SYSTEM_POWER_STATUS
Public ACLineStatus As Byte
Public BatteryFlag As Byte
Public BatteryLifePercent As Byte
Public Reserved1 As Byte
Public BatteryLifeTime As Integer
Public BatteryFullLifeTime As Integer
End Structure
Public Function BatteryStatus() As SYSTEM_POWER_STATUS
Try
Dim ps As New SYSTEM_POWER_STATUS
GetSystemPowerStatus(ps)
Return ps
Catch ex As Exception
Debug.WriteLine(ex.Message )
End Try
End Function
Public Structure SYSTEM_POWER_STATUS
Public ACLineStatus As Byte
Public BatteryFlag As Byte
Public BatteryLifePercent As Byte
Public Reserved1 As Byte
Public BatteryLifeTime As Integer
Public BatteryFullLifeTime As Integer
End Structure
Public Function BatteryStatus() As SYSTEM_POWER_STATUS
Try
Dim ps As New SYSTEM_POWER_STATUS
GetSystemPowerStatus(ps)
Return ps
Catch ex As Exception
Debug.WriteLine(ex.Message
End Try
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER