DWORD t0;
ofs=0;
t0=GetTickCount();
while(GetTickCount()-t0 < 5000)
{
}
Example Code
The following example demonstrates how to handle timer wrap around.
DWORD dwStart = GetTickCount(); // Stop if this has taken too long if( GetTickCount() - dwStart >= TIMELIMIT ) Cancel();
这个函数是取得程序运行到现在的时间,这样在检测代码的前后各运行一次这个函数,两次的差就是程序运行的大概的时间了