INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

API Functions

How long the system is running since last boot by AirCon
Posted: 6 Nov 03 (Edited 8 Nov 03)

This function will determine how long the system has been running since the last time we start up (boot) the system.

Notes: the return value is DWORD (32bit unsigned long). So it will wrap around (reset) to zero if the system run continuously for 49.7 days.

Enjoy!


*** Example
#Define CR   chr(13)

Local lcOldEscape
Local lnDays, lnHours, lnMinutes, lnSeconds

lcOldEscape = set('escape')
Set escape off
Set decimals to 3
Do while (lastkey() != 27)
    GetSystemElapsedTime(@lnDays, @lnHours, @lnMinutes, @lnSeconds)
    Wait 'Windows has been running for: ' + CR + CR + ;
        alltrim(transform(lnDays, '99 days')) + CR + ;
        alltrim(transform(lnHours, '99 hours')) + ', ' + ;
        alltrim(transform(lnMinutes, '99 minutes')) + ', ' + ;
        alltrim(transform(lnSeconds, '99.999 seconds')) + CR + CR + ;
        'Press ESC to close...' window nowait noclear
    = inkey(0.1, 'HM')
enddo
Set decimals to
Set escape &lcOldEscape
Wait clear
** Clear Dlls GetTickCount


*** The function
Procedure GetSystemElapsedTime(tnDays, tnHours, tnMinutes, tnSeconds)
    Local lnTick

    Declare Long GetTickCount in Kernel32

    lnTick = GetTickCount()
    tnHours = int(lnTick / 3600000)
    If (tnHours > 23)
        tnDays = int(tnHours/24)
        tnHours = mod(tnHours, 24)
    else
        tnDays = 0
    endif
    lnTick = mod(lnTick, 3600000)
    tnMinutes = int(lnTick / 60000)
    tnSeconds = Mod(lnTick, 60000) / 1000
EndProc
*****************
*** End function
*****************



Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close