Windows Mobile 6.5
A version of this page is also available for

This function returns the amount of time, in milliseconds, that the system has been idle.

DWORD GetIdleTime (void);


The number of milliseconds that the system has been idle. If GetIdleTime returns MAXDWORD, this functionality is not supported by your platform.

The following code example shows how to determine how long the device has idled by wrapping a call to GetIdleTime with calls to GetTickCount.

dwStartTick = GetTickCount();
dwIdleSt = GetIdleTime();
//  You must insert a call to the Sleep(sleep_time) function to allow
//  idle time to accrue. An example of an appropriate sleep time is
//  1000 ms.
dwStopTick = GetTickCount();
dwIdleEd = GetIdleTime();
PercentIdle = ((100*(dwIdleEd - dwIdleSt)) / (dwStopTick - dwStartTick));

Windows Embedded CEWindows CE 3.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions