• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1409
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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