2012-04-27 7 views
2

私のVB.Netプロジェクトでフレームワーク2.0を使用するには、ラップトップまたはノートブックの現在のバーティーライフをコーディングする必要があります。私のラップトップのバッテリー寿命をVB.NETで確認する

現在のバッテリステータス情報を取得できますか?

+0

このコードを試すことができますが、既製のコードです - http://syntaxhelp.com/VB.NET/Retrieve -battery-info –

答えて

9

あなたがここに

Dim power As SystemInformation.PowerStatus = SystemInformation.PowerStatus 
Dim percent As Single = power.BatteryLifePercent 
MsgBox("Percent battery life remaining: " & percent * 100) 
6

SystemInformationクラス、具体的にはPowerStatusプロパティ(のインスタンスを返す)を確認してください。コードはあなたの現在のバッテリ情報を提供します続き

Dim powerstatus As PowerStatus = SystemInformation.PowerStatus 

' Gets the current battery charge status. 
MessageBox.Show("BatteryChargeStatus : " & powerstatus.BatteryChargeStatus) 

' Gets the reported full charge lifetime of the primary battery power source in seconds. 
MessageBox.Show("BatteryFullLifetime : " & powerstatus.BatteryFullLifetime) 

' Gets the approximate amount of full battery charge remaining. 
MessageBox.Show("BatteryLifePercent : " & powerstatus.BatteryLifePercent) 

' Gets the approximate number of seconds of battery time remaining. 
MessageBox.Show("BatteryLifeRemaining : " & powerstatus.BatteryLifeRemaining) 

' Gets the current system power status. 
MessageBox.Show("PowerLineStatus : " & powerstatus.PowerLineStatus) 
関連する問題