You can use GetSystemTimeAsFileTime
to get the current time as a FILETIME
. Create a SYSTEMTIME
representing your desired epoch (1/1/1970) and call SystemTimeToFileTime
to convert it to a FILETIME
. Subtract the two FILETIME
s and scale to your desired accuracy (from 100ns units to 1ms units).
This will give you the current UTC time. If you need the local time, you'll need to convert to local time using e.g. SystemTimeToTzSpecificLocalTime
.