原创 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);//比较终止值
}
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
4
关闭 站长推荐上一条 /3 下一条