Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: uptime for Win XP?

Thread Tools

Re: uptime for Win XP?

Andrey Ivanov
Posts: n/a
>> I believe that "uptime" works from the console, but don't have a machine
>> to check it with...

> Doesn't work for me, but if you have win32all installed, you can get it
> from Python:
> >>> import win32api
> >>> print "Uptime:", win32api.GetTickCount(), "Milliseconds"

> Uptime: 148699875 Milliseconds

MSDN recommends another approach. They say, that you should retrieve
the value of "System Up Time" counter from HKEY_PERFORMANCE_DATA. In
theory, you can do it without win32all, by using _winreg module. All
you need is to know a counter index, which can be fetched from
registry. On my system "System Up Time" counter has index "674", so
Python code should look like this:

>>> import _winreg
>>> value, type_code = _winreg.QueryValueEx(_winreg.HKEY_PERFORMANCE_DATA , "674")
>>> print "Uptime: %s miliseconds" % (value,)

But in current implementation of _winreg it doesn't work. I've checked
the sources and found that current implementation doesn't handle
ERROR_MORE_DATA, which prevents it from retrieving any performance
counters. I'm thinking of bug/patch submission.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Applet to run on Win 98, Win ME, Win XP, Win Vista & Win 7 ?? Krist Java 6 05-06-2010 11:53 PM
Re: uptime for Win XP? Andrey Ivanov Python 2 12-13-2004 08:10 PM
RE: uptime for Win XP? Tim Golden Python 1 12-13-2004 05:47 PM
uptime for Win XP? Esmail Bonakdarian Python 24 12-13-2004 03:12 PM
5509 uptime Trash Cisco 2 11-16-2003 11:52 PM