[fpc-pascal] The unfortunate deprecation of GetTickCount
Tobias Giesen
tobiasgiesen at gmail.com
Wed Apr 11 13:59:56 CEST 2018
Hello,
personally I use this 64 bit emulation:
var CurrentIncrement:Int64=0;
LastTickCount:Int64=0;
function TGGetTickCount64:Int64;
begin
{$ifdef CPUX64}
Result:=GetTickCount64;
{$else}
Result:=GetTickCount+CurrentIncrement;
if Result<LastTickCount then begin
Inc(Result,Int64($100000000));
Inc(CurrentIncrement,Int64($100000000)); // only 99.999999% thread safe but good enough for me
end;
{$endif}
LastTickCount:=Result;
end;
Kind Regards,
Tobias Giesen
----
On Wed, 11 Apr 2018 12:25:16 +0200
Luca Olivetti <luca at ventoso.org> wrote:
> El 11/04/18 a les 10:06, Luca Olivetti ha escrit:
> >
> > BEFORE (with gettickcount):
> >
> > ----------------------------------------------------------------------
> > var PreviousTick:DWORD;
> >
> > ...
> > PreviousTick:=GetTickCount;
> > ...
> > ... if DWORD(GetTickCount-PreviousTick)>WaitTime then....
>
>
> BTW, the DWORD typecast is only necessary with fpc, the following
> program gives 4 and 4 if compiled with delphi 2, 4 and -4294967292 if
> compiled with fpc 3.0.4
>
>
> program project1;
>
> uses
> windows;
>
> var t1,t2,t3:dword;
> begin
> t1:=$fffffffe;
> t2:=2;
> t3:=t2-t1;
> writeln(t3);
> writeln(t2-t1);
> end.
>
>
> --
> Luca
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Kind Regards,
Tobias Giesen
Super Flexible Software Ltd. & Co. KG
Buddenstr. 29-31
48143 Münster, Germany
www.superflexible.com
www.tgtools.com
-----------------------------------------------------------
Registered at register court Münster as HRA 9716
Liability / general partner: TGTools Ltd.
Company No. 05513299
Registered in England and Wales
Directors: Tobias Giesen and Claudia Giesen
More information about the fpc-pascal
mailing list