How to receive battery information using the WinAPI
Posted
by ShadowLord ShadowLord
on February 5th, 2004
The program utilises the following API call's and structure to obtain the information :
private Declare Function GetSystemPowerStatus Lib "kernel32" _
(lpSystemPowerStatus as SYSTEM_POWER_STATUS) as Long
private Declare Function SetSystemPowerState Lib "kernel32" _
(byval fSuspend as Long, byval fForce as Long) as Long
private Type SYSTEM_POWER_STATUS
ACLineStatus as Byte 'Checks to see if you're connected to the
'wall outlet or not
BatteryFlag as Byte 'Battery status
BatteryLifePercent as Byte 'precentage left
Reserved1 as Byte 'Dont use
BatteryLifeTime as Long 'Total time left of your battery
BatteryFullLifeTime as Long 'Total UPtime of your battery
End Type
As you can see, it takes up much less space in your program and distributable than the 67k required by SysInfo.ocx

Comments
There are no comments yet. Be the first to comment!