PDA

Vollständige Version anzeigen : Uptime anzeigen


fabia
24.08.2004, 08:17
Guten morgen

Weiss jemand ob es eine vordefinierte VB .NET Klasse gibt mit welcher man die aktuelle Uptime eines Windows System anzeigen kann?

gruss Fabia

chrissy
24.08.2004, 10:17
Hallo,

System.Environment bietet diese Möglichkeit.

Versuch das mal:

Class Uptime

Private _h As Integer
Private _d As Integer
Private _m As Integer
Private _s As Integer

Public Property Hours() As Integer
Get
Return _h
End Get
Set(ByVal Value As Integer)
_h = Value
End Set
End Property

Public Property Days() As Integer
Get
Return _d
End Get
Set(ByVal Value As Integer)
_d = Value
End Set
End Property

Public Property Minutes() As Integer
Get
Return _m
End Get
Set(ByVal Value As Integer)
_m = Value
End Set
End Property

Public Property Seconds() As Integer
Get
Return _s
End Get
Set(ByVal Value As Integer)
_s = Value
End Set
End Property

Public Sub ComputeUpTime()

Dim nTicks As Integer

nTicks = Environment.TickCount
nTicks = nTicks / 1000
Days = Int(nTicks / (3600 * 24))
nTicks = nTicks - (Int(nTicks / (3600 * 24)) * (3600 * 24))
Hours = Int(nTicks / 3600)
nTicks = nTicks - (Int(nTicks / 3600) * 3600)
Minutes = Int(nTicks / 60)
nTicks = nTicks - (Int(nTicks / 60) * 60)
Seconds = nTicks

End Sub

End Class

Gruß

Chris