728x90
Public Class Form1
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
timer1.Interval = 1000 '1초마다...
End Sub
Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
MyBase.OnClosed(e)
timer1.Stop()
End Sub
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
timer1.Start()
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
timer1.Stop()
End Sub
Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer1.Tick
Dim psStatus As PowerStatus = SystemInformation.PowerStatus
'충전 상태
txtChargeStatus.Text = psStatus.BatteryChargeStatus.ToString()
'전원 상태
txtPoerStatus.Text = psStatus.PowerLineStatus.ToString()
'충전 비율
If psStatus.BatteryLifePercent <> 255 Then
pbCharge.Value = Convert.ToInt32(psStatus.BatteryLifePercent * 100)
Else
pbCharge.Value = 0
End If
'잔여 사용 시간
If psStatus.BatteryLifeRemaining <> -1 Then
textBox1.Text = TimeSpan.FromSeconds(psStatus.BatteryLifeRemaining).ToString()
Else
textBox1.Text = "-------"
End If
'완충시 사용 시간
If psStatus.BatteryFullLifetime <> -1 Then
textBox2.Text = psStatus.BatteryFullLifetime.ToString()
Else
textBox2.Text = "-------"
End If
End Sub
End Class
728x90
'자료' 카테고리의 다른 글
[VB.NET/C#] Network MacAddress (0) | 2021.04.09 |
---|---|
[C#/VBNET] [WMI] 그래픽 카드 정보 (0) | 2021.04.09 |
[PHP] json_encode 유니코드 한글 문제 해결 방법 (0) | 2021.03.26 |
아톰(atom) 필수 설치 플러그인 (0) | 2021.03.25 |
JQuery ajax + PHP 예제 (0) | 2021.03.22 |