Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pascal 已执行函数的计时器返回零_Pascal_Freepascal - Fatal编程技术网

Pascal 已执行函数的计时器返回零

Pascal 已执行函数的计时器返回零,pascal,freepascal,Pascal,Freepascal,linux上的endtime返回结果0。对于给定的睡眠功能,它应该是以毫秒为单位的返回数。在GUI的标签上显示0 以下是代码: var starttime: longint; var endtime: longint; function GetTickCount : DWORD; begin {$IFDEF MSWINDOWS} Result := Windows.GetTickCount mod High(LongInt); {$ELSE} Result := GetTickCoun

linux上的endtime返回结果
0
。对于给定的睡眠功能,它应该是以毫秒为单位的返回数。在GUI的标签上显示
0

以下是代码:

var starttime: longint;
var endtime: longint;

function GetTickCount : DWORD;
begin
{$IFDEF MSWINDOWS}
  Result := Windows.GetTickCount mod High(LongInt);
{$ELSE}
  Result := GetTickCount mod High(LongInt);
{$ENDIF}
end;



procedure TForm1.Button4Click(Sender: TObject);
begin

  starttime:=getTickCount;

  // something do...

  Sleep(1500); // sleep in miliseconds, works!

  endtime:=getTickCount-starttime;

  Label1.Caption:=inttostr(endtime);  // returns 0 ?

end;

gettickcount函数{$else}中的gettickcount被解释为过程的返回值。(德尔菲结果)

根据模式的不同,这可能导致永久递归

解决方案:就像在windows中一样,使用unitname进行限定

   {$else}
        Result := SysUtils.GetTickCount mod High(LongInt);

在Linux上,如果我像前面提到的那样更改为,它将不起作用。标识符没有找到“GetTickCount”。事实上,这似乎是一个主干(开发)功能,尚未发布版本。我也用Lazarus在Windows上测试过,似乎在Windows上不起作用。是否有其他方法来实现计数器?