In this article I will
show you how to show battery status of laptop battery like its battery is discharging,
charging, full etc. We will do this using WMI because WMI have power to answer
questions about battery status .So let's start with WMI.
To access account information of Battery we need
to Use System. Managementname space.
To use this name space first of all we need to add
reference to System.management by
Project Menu>>Add Reference.
after that at the top of the code use
using System.Management;
so that you can use of
its classes .Now its simple to get information about laptop Battery through querying ManagementObjectSearcher Class .
We can get all information about Laptop Battery through
Win32_Battery class.
so we need to query on that class to get related
Management object and then we just need to get various properties related to it
.
setup interface like below on the form
here i have taken two labels one textbox with read only property and one progress bar and a timer control .
now to get battery status we need to code like below .
Zaid KhanPosted Apr 13, 2015, 6:55 AM
My Mail ID [email protected]
Zaid KhanPosted Apr 13, 2015, 6:02 AM
it s not working I run the code I didn;t get the batter name even and even it s not going inside the loop
JayPosted Apr 19, 2011, 5:34 AM
do you know how to disable and enable battery charge?
kevin shahPosted Feb 2, 2011, 2:12 AM
Hello sir.. You have done some nice work on Aps.net
Mahesh ChandPosted Aug 8, 2010, 12:03 PM
Interesting. I didn't know how to do that :)