dwStartTick = GetTickCount();
dwIdleSt = GetIdleTime();
// 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));