原创
API函数uS级延时的方法
2008-10-20 19:55
3801
4
4
分类:
软件与OS
void CAddressAssistDlg::Delay(DWORD uSTimes)
{
LARGE_INTEGER litmp;
LONGLONG dwFreq, dwuSTimes, dwQPartx, dwQPart, dwQPart0;
QueryPerformanceFrequency(&litmp);
dwFreq = litmp.QuadPart;//获得计数器的时钟频率
dwQPartx = uSTimes * dwFreq / 1000000;//获得终止值
QueryPerformanceCounter(&litmp);
dwQPart0 = litmp.QuadPart;//获得初始值
do
{
QueryPerformanceCounter(&litmp);
dwQPart = litmp.QuadPart;//获得当前值
if(dwQPart > dwQPart0)
{
dwuSTimes = dwQPart - dwQPart0;
}
else
{
dwuSTimes = dwQPart0 - dwQPart;
}
} while (dwuSTimes < dwQPartx);//比较终止值
}
文章评论(0条评论)
登录后参与讨论