WINCE 微秒、毫秒级延时函数

  
    
void delay_us( int n){

LARGE_INTEGER litmp;
LONGLONG QPart1,QPart2;
double dfMinus, dfFreq, dfTim;
if (QueryPerformanceFrequency( & litmp) == FALSE)
{
MessageBox(NULL,TEXT(
" Error:QueryPerformanceFrequency " ),TEXT( " Error " ),MB_OK);
return ;
}
dfFreq
= ( double )litmp.QuadPart;
QueryPerformanceCounter(
& litmp);
QPart1
= litmp.QuadPart;
do
{
QueryPerformanceCounter(
& litmp);
QPart2
= litmp.QuadPart;
dfMinus
= ( double )(QPart2 - QPart1);
dfTim
= dfMinus / dfFreq;
}
while (dfTim < 0.000001 * n);

}
// 毫秒级的延时函数
void delay_ms(DWORD tmp_time)
{
DWORD start;
DWORD time_i
= 0 ;
start
= GetTickCount();
while (time_i <= tmp_time)
{
time_i
= GetTickCount() - start;
}
}

 

转自:http://blog.163.com/mg29_x/blog/static/60304826200812911148146/

你可能感兴趣的:(WinCE)