Compartilhar via


GetTickCount (Windows CE 5.0)

Send Feedback

For Release configurations, this function returns the number of milliseconds since the device booted, excluding any time that the system was suspended. GetTickCount starts at 0 on boot and then counts up from there.

For Debug configurations, 180 seconds is subtracted from the the number of milliseconds since the device booted. This allows code that uses GetTickCount to be easily tested for correct overflow handling.

DWORDGetTickCount(void);

Return Values

The number of milliseconds indicates success.

Remarks

The resolution of the system timer is based on the OEM's setting. Check with the OEM for details.

The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days.

For Debug configurations, 180 seconds is subtracted to check for overflow conditions in code that relies on GetTickCount. If this code started within 3 minutes of the device booting, it will experience an overflow condition if it runs for a certain amount of time.

Note   You should not use GetTickCount for drift sensitive applications.

When using GetTickCount, subtraction is safe but comparisons such as if (GetTickCount() > MyTickCount) are not. You can use the GetTickCount function to time the duration of an activity as shown in the example below, but using GetTickCount for any other operation will cause issues.

dwOldTime = GetTickCount();
DoSomething();
dwTimeElapsed = GetTickCount() – dwOldTime;

On the STMicro platform, the time returned by GetTickCount includes a ~0.014% time drift, which is by design. This translates to a time lag of approximately 1 second every 2 hours.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

See Also

Time Functions | GetSystemTime | SetSystemTime | Timer Driver Reference

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.