0

I'm trying to get the uptime of a windows machine using ctypes.windll.kernel32.GetTickCount64. I'm not sure what it's giving me though, I thought it was supposed to be the number of ticks since the systems started in milliseconds. It seems to be a negative number which is going down though. I read somewhere that it's an unsigned int, but it seems like a regular int to me.

import ctypes
import time
for _ in range(10):
    print ctypes.windll.kernel32.GetTickCount64()
    time.sleep(1)

-1514476171
-1514475171
-1514474156
-1514473156
-1514472156
-1514471156
-1514470156
-1514469156
-1514468156
-1514467140

How can I convert this value to get an uptime in seconds? Or is there a better way to get this information?

ninhenzo64
  • 702
  • 1
  • 9
  • 23
  • not sure why this was marked as a duplicate - the linked article is pretty abstract. this is the solution though: `ctypes.windll.kernel32.GetTickCount64.restype = int` – ninhenzo64 Jun 06 '21 at 16:51
  • It’s a duplicate because 99.9% of ctypes answers tell you to set `restype` and `argtypes`, but the return type of GetTickCount64 is ULONGLONG which is `c_uint64` not `int`. – Mark Tolonen Jun 07 '21 at 01:11

0 Answers0