LARGE_INTEGER litmp; //The LARGE_INTEGER structure is used to represent a 64-bit signed integer value.
LONGLONG QPart1,QPart2; // 声明2个长整型
double dfMinutes,dfFreq,dfTim;//声明2个双精度类型
QueryPerformanceFrequency(&litmp);
dfFreq=(double)litmp.QuadPart;
QueryPerformanceCounter(&litmp);
QPart1=litmp.QuadPart;
Sleep(100);
QueryPerformanceCounter(&litmp);//获得中止的数值
QPart2=litmp.QuadPart;
dfMinutes=(double)(QPart2-QPart1);
dfTim=dfMinutes/dfFreq;
Edit1->Text=FloatToStr(dfTim);
计算时间间隔
本文介绍了一种使用LARGE_INTEGER结构和QueryPerformanceCounter函数来精确测量时间间隔的方法。通过两次获取计数器的时间点并进行对比,可以计算出毫秒级的时间差。
2110





