Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
HowTo: How to use the PowerStatus in System.Windows.Forms.SystemInformation


One of the new cool new classes in .net 2.0 is the PowerStatus class (http://msdn2.microsoft.com/en-us/library/system.windows.forms.systeminformation.powerstatus(VS.80).aspx ).  You can use this class to get information about the battery life of your mobile computer.  In my case this is for a Tablet PC application that I am working on for work.

For our project we wanted to get the battery life information for a Tablet PC and display to the user both the amount battery life lift as well as display a visual indicator when the battery goes below a wired percentage.  For this post, I am just going to give a simple overview of some of the different things you can do with this class.


1) Get the Power Status
Gets the current system power status.

2) Get the Charge Status
Gets the current battery charge status.

3) Get the Battery Life Percent
Gets the approximate percentage of the full battery left.

4) Get the Battery Life Remaining
Gets the approximate number of seconds of the battery time remaining.

 

5) Get the Full Life Amount for the Battery
Gets the reported full charge lifetime of the battery power source in seconds. 

There you have it, a clean and simple way to use the PowerStatus class in .net.   The namespace that this class belongs to ystem.Windows.Forms.SystemInformation has some pretty cool little features in it.  You should check it out at http://msdn2.microsoft.com/en-us/library/system.windows.forms.systeminformation_properties(VS.80).aspx

***
Hope everyone has a great Thanksgiving, I'm off till next week....
***

 

dp.SyntaxHighlighter.HighlightAll('code');

Posted 11-20-2006 8:46 PM by Derik Whittaker
Filed under: , ,

[Advertisement]

Comments

Rajith wrote re: HowTo: How to use the PowerStatus in System.Windows.Forms.SystemInformation
on 08-15-2008 1:17 PM

Well !!

I have already did this program for my own purpose for more info you can visit rajithprabhakar.googlepages.com..

What i want to tell you is, i am running vista basic, but the remaining time  "SystemInformation.PowerStatus.BatteryLifeRemaining"

it iwill not showing exact time for me its like '-1' for some others '0.00' while i googled..

What is your opinion about this ????

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)