GetTickCount函數

来源:互联网 发布:邮件整理软件 编辑:程序博客网 时间:2024/05/01 14:00

【函数名】
GetTickCount

【库名】
kernel32

【适用范围】
95/98/ME/NT/2000/XP

【VB声明】
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

【说明】  用于获取自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;

原创粉丝点击