Windows API Guide: GetLocalTime Function


Declare Function GetTickCount Lib "kernel32.dll" () As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Unknown.

Description & Usage

GetTickCount determines how much time has elapsed since Windows was last started. The time is measured in milliseconds, although the actual resolution of the function's output depends on that of the system timer itself. Therefore, it may not be perfectly accurate to the millisecond. Because of the limitations of the 32-bit integer data type, the reported elapsed time wraps back to zero after about 49.7 days of continuous operation.

Return Value

The function returns the number of milliseconds that have passed since Windows was last started.

Visual Basic-Specific Issues

None.

Parameters

None.

Example

' This code is licensed according to the terms and conditions listed here. ' Determine about how much time it takes for Visual ' Basic to compute the square root of a large number.  The elapsed ' time for that operation is displayed in seconds. Dim starttime As Long  ' timer value before the calculation Dim endtime As Long  ' timer value after the calculation Dim result As Double  ' receives result of square root operation ' Find how much time has passed since Windows was started. starttime = GetTickCount() ' Calculate the square root of a large number. result = Sqr(54761) ' Find how much time has now passed since startup. endtime = GetTickCount() ' The difference between starttime and endtime is the time it took ' to calculate the square root. Debug.Print "The calculation took"; (endtime - starttime) / 1000; "seconds."

Category

Time

Back to the Function list.
Back to the Reference section.


Last Modified: March 19, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/gettickcount.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net