A NOTE TO ANYONE USING THE ABOVE CODE:
I made a slight error in the definitions of the SECS_TO_TICKS and MSECS_TO_TICKS macros. You'll need to change them to the following:
Code:
#define SECS_TO_TICKS(a) ( ((long)(a)) * 10000 / 262 )
//And milliseconds too:
#define MSECS_TO_TICKS(a) ( ((long)(a)) * 10 / 262 )
otherwise, the values will overflow for a value greater than about 3 seconds.