Source code berikut merupakan suatu
program untuk dapat mengetahui System Uptime
Copy coding dibawah ini dan paste di Editor Form:
'---Form Usage Example:---'
Private Sub Timer1_Timer()
Label1 = "System Uptime: " & SystemUptime.Days & " Days, " & _
SystemUptime.Hours & " Hours, " & _
SystemUptime.Minutes & " Mins, " & _
SystemUptime.Seconds & " Seconds, " & _
SystemUptime.MSeconds & " Miliseconds"
End Sub
Copy coding dibawah ini dan paste di Editor Module:
'---In Module---'
Public Type TimeConv
Days As Long
Hours As Long
Minutes As Long
Seconds As Long
MSeconds As Long
End Type
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Function ConvertTime(ByVal Tick As Long) As TimeConv
ConvertTime.MSeconds = Tick Mod 1000
Tick = Tick \ 1000
ConvertTime.Days = ((Tick) \ (24 * (60 ^ 2)))
If ConvertTime.Days > 0 Then Tick = (Tick - 24 * (60 ^ 2)) * ConvertTime.Days
ConvertTime.Hours = Tick \ (60 ^ 2)
If ConvertTime.Hours > 0 Then Tick = Tick - ((60 ^ 2) * ConvertTime.Hours)
ConvertTime.Minutes = Tick \ 60
ConvertTime.Seconds = Tick Mod 60
End Function
Property Get SystemUptime() As TimeConv
SystemUptime = ConvertTime(GetTickCount)
End Property
Tidak ada komentar:
Posting Komentar