To clarify, I mean time spent while the system is suspended/hibernated, not the calling thread (GetTickCount() returns the number of milliseconds since system boot).
As far as I know, GetTickCount is unrelated to threads and counts the time since the system has started. But it is better to use GetTickCount64 to avoid the 49.7 day roleover.
By the way, to get what you want you need the GetThreadTimes function. It records the creation and exit time and the amount of time the thread has spend in user or kernel space. So you have a nice way to calculate the amount of time spend.
Ok, I missed the "system" part of the question. But that is simple. When in hibernation GetTickCount continues the counting. Because people have suffered from the 49.7 days bug when the computer was in hibernate most of the time. See link text here for more information.
GetTickCount()
gives you the time in milliseconds since the computer booted. it has nothing to do with the process calling it.
Short answer : Yes.
Longer answer: Read the GetTickCount() docs: It's the elapsed time since system startup, and even MS wouldn't suggest that time stands still while your computer is hibernating...
no, GetTickCount() does not include the time the system spend during hibernate. a simple test may i prove so.
in python import win32api win32api.GetTickCount()
-- do hiberante --
win32api.GetTickCount()
and you'll see the result..
Yes, GetTickCount does include suspend/hibernate time.
In the following python script I call the Sleep API to wait 40 seconds to give me a chance to put the computer into hibernate mode, and I print the time before and after, and the tick count difference after.
import win32api import time print time.strftime("%H:%M:%S", time.localtime()) before = win32api.GetTickCount() print "sleep" win32api.Sleep(40000) print time.strftime("%H:%M:%S", time.localtime()) print str(win32api.GetTickCount()-before)
Output:
17:44:08 sleep 17:51:30 442297
If GetTickCount did not include the time during hibernate it would be much less than the time I hibernated for, but it matches the actual time elapsed (7 minutes 22 seconds equals 442 seconds, i.e. 442000 millisecond "ticks").