System Uptime

Discussion in 'Archives' started by Arkane, Jul 12, 2007.

System Uptime
  1. Unread #1 - Jul 12, 2007 at 3:42 AM
  2. Arkane
    Referrals:
    0

    Arkane Guest

    System Uptime

    Get the current System Uptime and convert to days/hours/minutes/seconds/miliseconds, place in a module to use.

    Code:
    '---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
     
     
    '---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
    Feedback is welcomed, suggestions are also welcomed.
     
  3. Unread #2 - Jul 12, 2007 at 5:48 AM
  4. Jazz00006
    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0

    Jazz00006 Apprentice
    Visual Basic Programmers

    System Uptime

< sellin amazing pure str!!!!!! | Selling 150m ~NO Paypal~ >

Users viewing this thread
1 guest


 
 
Adblock breaks this site