Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access tablet battery status 2

Status
Not open for further replies.

AlastairP

Technical User
Feb 8, 2011
286
AU
I have a VP9 application running on a windows tablet that runs full screen including hiding the task bar.
I would like to access the battery life information so I can display the info in the application.

Anyone know how that can be done?

Alastair
 
Alastair,

Check the Win32_Battery class at
A sample usage:

Code:
CLEAR

LOCAL BStatus AS String

TEXT TO m.BStatus NOSHOW
:1:Discharging:
:2:Connected to AC:
:3:Fully charged:
:4:Low:
:5:Critical:
:6:Charging:
:7:Charging and high:
:8:Charging and low:
:9:Charging and critical:
:10:Undefined:
:11:Partially charged:
ENDTEXT

LOCAL WMIService, AllBatteries, Battery

m.WMIService = GETOBJECT("winmgmts:\\.\root\cimv2")

m.AllBatteries = m.WMIService.ExecQuery("SELECT * FROM Win32_Battery",,48)

FOR EACH m.Battery IN m.AllBatteries

	? "Battery status:", STREXTRACT(m.BStatus, TEXTMERGE(":<<m.Battery.BatteryStatus>>:"), ":")
	? "Charged at", TRANSFORM(m.Battery.EstimatedChargeRemaining), "%"

ENDFOR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top