Anyone have code for obtaining the "real" Windows uptime that works around the 49 day limitation of GetTickCount?
Constraints: The existing program that will need to display the uptime will be run at least once per day, and may also be running continuously (but not necessarily).
The solution needs to work only on Win2k and XP (and above) platforms - Win98/95/ME support is not required. It would be best if the solution did not depend on either a continuously-running service or something that needs to auto-start when Windows reboots. NOTE: One-second resolution is more than acceptable, therefore a Cardinal variable could be used to store the value, with a very acceptable rollover of about 136 YEARS
Some thoughts about how this might be done (need help fleshing them out or new ideas):
1- The first time that the main program runs, have it write an integer var somewhere into Windows memory that won't get wiped out when the main program ends (how to do that? Dunno). That number would be incremented each time a rollover is detected (by the main program) to track the number of rollovers. Rebooting Windows would wipe out that RAM-resident value, therefore resetting it.
2- Use some other counter value from Windows, perhaps the Performance Counters (exactly how, though?).
3- Write a Windows service that runs when Windows boots and provides this service, based on GetTickCount, but with a local variable to track rollovers. The Main program would access this service to get the real uptime. This is probably acceptable, but as noted above, not a very satisfactory or desirable solution.
Anyione have any other solutions?