本文整理自网络,侵删。
// 高精度的延时,精确到Ms , 100ms以内采用,或要求误差极小// 删除Application.ProcessMessages 影响精度procedure DelayMsEx(Ms: LongWord);var iFreq, iStartCounter, iEndCounter: Int64;begin QueryPerformanceFrequency(iFreq); QueryPerformanceCounter(iStartCounter); repeat QueryPerformanceCounter(iEndCounter); //Application.ProcessMessages; until ((iEndCounter - iStartCounter) >= Round(Ms * iFreq / 1000 ));end; // 精度很低,50ms以外还能凑活// 及时去除 Application.ProcessMessages 误差也极大// 仅适用误差要求不高,延时较长的场合procedure DelayMs(Ms: LongWord);var dwStartTime: LongWord;begin dwStartTime := GetTickCount; repeat Application.ProcessMessages; until ((GetTickCount - dwStartTime) >= Ms);end;
来源:https://blog.csdn.net/w709835509/article/details/17486943
相关阅读 >>
Delphi iddecodermime 对图像编码base64解码成图像文件
Delphi recodedatetime、recodedate、recodetime、recodeyear ... 修改时间
Delphi中输入框不能输入初数字意外的字符串的函数(isnumeric)
Delphi tms web core twebhttprequest使用
Delphi webservices 字节数组 base64编码
更多相关阅读请进入《Delphi》频道 >>