Delphi延时


本文整理自网络,侵删。

 
// 高精度的延时,精确到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与sql server存储过程编程详解

Delphi 将字符串转换成 utf8 编码的函数

Delphi monthcalendar1 获取选中日期

Delphi 取键盘值

Delphi 几种程序自杀的方法

Delphi 快速读取txt 指定行的数据

Delphi tdragimage v0.1 Delphi 图片拖拽组件 带有加速度 碰撞效果

Delphi入门语法

Delphi 获取当前鼠标指针位置文本

Delphi savedialog覆盖询问

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...