|
-
Dec 22nd, 2001, 09:04 PM
#1
Thread Starter
Lively Member
Why we hate GetSystemPowerStatus.
Greetings all.
I find that whenever I use the GetSystemPowerStatus API call it returns 255% battery life. This is obviously impossible, and it quite irritating. However, if I pop open Control Panel and look at the battery meter there- Magic! GetSystemPowerStatus starts reporting the right percentage until the next reboot.
My question is: How to I make GetSystemPowerStatus to behave properly through code? Is there some kind of flag I need to set with another API call?
~Zero the Inestimable
-
Dec 23rd, 2001, 12:02 AM
#2
VB Code:
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
Private Sub Form_Paint()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
Dim SPS As SYSTEM_POWER_STATUS
'get the battery powerstatus
GetSystemPowerStatus SPS
Me.AutoRedraw = True
'show some information
Select Case SPS.ACLineStatus
Case 0
Me.Print "AC power status: Offline"
Case 1
Me.Print "AC power status: OnLine"
Case 2
Me.Print "AC power status: Unknown"
End Select
Select Case SPS.BatteryFlag
Case 1
Me.Print "Battery charge status: High"
Case 2
Me.Print "Battery charge status: Low"
Case 4
Me.Print "Battery charge status: Critical"
Case 8
Me.Print "Battery charge status: Charging"
Case 128
Me.Print "Battery charge status: No system battery"
Case 255
Me.Print "Battery charge status: Unknown Status"
End Select
End Sub
-
Dec 23rd, 2001, 12:04 AM
#3
It return 255% to me to so I thinkg it's normal...
-
Dec 23rd, 2001, 08:57 AM
#4
Thread Starter
Lively Member
...
Well that's just the point. 255% battery life is not normal.
Obviously the Windows Power Meter is initializing something that gets the API to work. What is it?
~Zero the Inestimable
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|