Jul 4, 2009

Api: Timegettime() - timeGetTime() returns negative value

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > Others

Api: Timegettime() - timeGetTime() returns negative value

Galahad
Ok, I have this weird problem, using timeGetTime() API. I'm using it in a small application, that shows current system up-time. Now, it has been working fine, but at some point, it started returning negative values, and it counts backwards (decrementing the value)...

I don't know if system uptime has anything to do with it; my system has been running for approximately 690 hours, and I first noticed a problem a few days back. Now, I know there is perfectly reasonable explanation for this, but it escapes me. I tried searching for this problem on the web, but had no success.

For example, timeGetTime() at some point started returning negative values: -2484000000, and counts down, to -2483999999, -2483999998, etc...

Is it just my comp freaking out, or Windows was not designed to run for so long? laugh.gif I don't want to restart it, but if that's the only way... smile.gif

Oh, btw, I'm using it inside Visual Basic app, but I would hope that has nothing to do with this weird problem biggrin.gif

Thanx in advance...

 

 

 


Comment/Reply (w/o sign-up)

tzenes
This is a flaw in the windows timeGetTime function (not a bug), and is deterministic behaviour.

The windows SDK states:
QUOTE
Note that the value returned by the timeGetTime function is a DWORD value. The return value wraps around to 0 every 2^32 milliseconds, which is about 49.71 days. This can cause problems in code that directly uses the timeGetTime return value in computations, particularly where the value is used to control code execution. You should always use the difference between two timeGetTime return values in computations.


so every ~50 days one of your counters will reset before the other does
and when you take the difference of the two you will get a negitive number.

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Api Timegettime Timegettime Returns Negative


    Looking for api, timegettime, timegettime, returns, negative

Searching Video's for api, timegettime, timegettime, returns, negative
See Also,
advertisement


Api: Timegettime() - timeGetTime() returns negative value

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com