This sample show’s how to retrieve the current battery information for your laptop without the need for the SysInfo.ocx control.
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