We help IT Professionals succeed at work.

GetTickCount - Range Check Error

wolsen
wolsen asked
on
Medium Priority
1,525 Views
Last Modified: 2011-10-03
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?
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
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

Author

Commented:
I am using LongInt and maybe some integers, too.  I will try changing to DWORD, or equivalent.

Thank you.

Commented:
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;
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.