That is indeed the correct answer, Pawel, except it wraps every 49,7 days since its value is unsigned. And this has been a very old problem and every programmer could have known this. The issue is not even related to Freepascal but initially related to the Windows API.
It is also documented in the FPC manuals.
GetTickCount returns a cardinal
GetTickCount64 returns a Qword
Never use a signed integer type for either version.