Delphi中GetTickCount函数的使用
2016-12-06 18:37
621 查看
【函数名】 GetTickCount
【库名】 kernel32
【说明】 用于获取自windows启动以来经历的时间长度(毫秒)
【返回值】 Long,以毫秒为单位的windows运行时间
通常用来计算某个操作所使用的时间:
Start:=GetTickCount;
...//执行耗时的操作
Stop:=GetTickCount;
TimeUsed:=(Stop-Start)/1000; //使用了xxx秒
也可以用来做延时程序:
还可以用来判断和控制隔一段时间才执行一次的方法:
【库名】 kernel32
【说明】 用于获取自windows启动以来经历的时间长度(毫秒)
【返回值】 Long,以毫秒为单位的windows运行时间
通常用来计算某个操作所使用的时间:
Start:=GetTickCount;
...//执行耗时的操作
Stop:=GetTickCount;
TimeUsed:=(Stop-Start)/1000; //使用了xxx秒
也可以用来做延时程序:
Procedure TForm1.Delay(Msecs: Integer); var firstTickCount : real; begin firstTickCount := GetTickCount; Repeat Until ((GetTickCount - firstTickCount) >= longInt(Msecs)); end;
还可以用来判断和控制隔一段时间才执行一次的方法:
if ((GetTickCount - MktHQRefreshTime) div 1000) >= SSConfig.HqRefreshTime then //根据配置的时间回扫挂单 begin MktHQRefreshTime := GetTickCount; HSGDTradeTask(con); t4 := Now; AddLog(Format('行情回扫挂单,总耗时%5.2f ms', [(t4 - t3) * MSecsPerDay ])); end;
相关文章推荐
- Delphi 插件(Plug-ins)创建、调试与使用应用程序扩展(二)
- DELPHI下汉字输入法的编程及使用
- delphi中使用Report Machine解决中式带边条及固定行的疑难报表(上)
- Delphi使用VB编写的ActiveX控件全攻略
- 使用ACTIVEX和DELPHI开发串口通讯
- 在Delphi中使用指针参数
- 使用Delphi 發展商業物件
- 办公之星控件在Delphi里的使用
- 在delphi中使用xml文档有两种方法
- 关于Delphi中预编译指令的使用方法
- 使用Delphi获取系统信息
- 《关于VisiBroker For Delphi的使用》(2)
- 在Delphi中如何使用RC文件中的字符串表
- 详细教你如何使用delphi中thread的线程编程
- Delphi Win32 API 使用的特殊情况
- 使用Delphi获取系列信息
- Delphi下汉字输入法的编程及使用
- 使用Windows消息控制Winamp(Delphi)
- 简单使用Delphi中的TO-DO List
- 在Delphi中使用动态图标