【函數名】
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;