Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1367
  • Last Modified:

GetTickCount - Range Check Error

For some reason, the windows GetTickCount function causes a range check error.  This is according to bug report logs that I am receiving from my users.

Any ideas why this could be happening?  Can I safely ignore these errors by putting an exception handler around all calls to GetTickCount?
0
wolsen
Asked:
wolsen
  • 2
1 Solution
 
ricswikaCommented:
What data type are you assigning the result to? I use DWORD for this in my apps and don't have a problem.
0
 
necro_ccsCommented:
GetTickCount is defined as

DWORD GetTickCount(VOID)

I use a Cardinal for this (same as DWORD/LongWord) as well, and have never had a overflow issues
0
 
wolsenAuthor Commented:
I am using LongInt and maybe some integers, too.  I will try changing to DWORD, or equivalent.

Thank you.
0
 
ricswikaCommented:
Also make sure all of the other variables used in calcualations involving GetTickCount are DWORD or Cardinal. For, example this may cause an overflow issue. I think the compiler treats the calcuation as integer, thus the overflow.

var
  T: DWORD;
  T0 : Integer = 10;
  K: Integer = 100;

begin
  T := T0 + (GetTickCount*K);
end;
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now