Where is the GetTickCount after Delphi 6?

I am trying to migrate from Delphi 6 to Delphi 2010, but cannot find the GetTickCount function in Delphi 2010. I have IdGlobal , SysUtils and DateUtils in my use case.

 var RefreshTick : Cardinal; begin RefreshTick := GetTickCount; end; 

This gives me an error:

Undeclared Identifier: GetTickCount

What is the alternative to this?

+4
source share
4 answers

As you have since discovered, the GetTickCount function that you used was provided by the IdGlobal block. It had the same name as the Windows API function. The function you used is now called Ticks . Either add Windows to your proposal to get the API function, or change your code to use the new name instead.

It seems that the name change came in 2004. You should try to be more careful about updating your Indy library. Don't just use the version that comes with Delphi - it is probably out of date before you get it. Always download the latest version from the Indy control source.

+6
source

The GetTickCount function is part of a Windows device.

+8
source

GetTickCount is independent of the Delphi version, because it is a WinAPI function, and it must also be present in Delphi 2010, also in Delphi XE and XE2.

EDIT: Add a Windows block to the usage section.

0
source

With Lazarus 1.0.12, the following commands worked fine on windows:

Uses ... Windows ...

here is the code:

 Var initialtime, elapsedtime: DWord; . begin . initialtime := Windows.GetTickCount; . elapsedtime := Windows.GetTickCount - initialtime; WriteLn( 'Time elapsed: ' + IntToStr(elapsedtime) + ' miliseconds'); 
0
source

All Articles