Link to home
Start Free TrialLog in
Avatar of Neal Hartman
Neal HartmanFlag for United States of America

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


ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Neal Hartman

ASKER

I had byval in the api.