Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to track UPS/battery power
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01414516
Message ID:
01414523
Views:
76
This message has been marked as a message which has helped to the initial question of the thread.
>Anybody has experience to share of how to apply VFP to detect switching to UPS (when power failure), or just tracking battery power (either laptop or UPS) ?
lcComputer = "."
loWMIService = Getobject("winmgmts:\\" + lcComputer + "\root\cimv2")
colItems = loWMIService.ExecQuery("Select * from Win32_Battery")
For Each loItem In colItems
	?"Availability: " + Transform(loItem.Availability)
	?"Battery Status: " + Transform(loItem.BatteryStatus)
	?"Description: " + loItem.Description
	?"Design Voltage: " + loItem.DesignVoltage
	?"Device ID: " + loItem.DeviceID
	?"Estimated Run Time: " + Transform(loItem.EstimatedRunTime)+ " minutes"
	?"Name: " + loItem.Name
	?"Power Management Supported: " + Transform(loItem.PowerManagementSupported)
	?
Next
Previous
Reply
Map
View

Click here to load this message in the networking platform