Piotr Caban piotr.caban@gmail.com writes:
FILETIME ft_now, ft_epoch;
SYSTEMTIME st_epoch;
DOUBLE time_now, time_epoch;
memset(&st_epoch, 0, sizeof(SYSTEMTIME));
st_epoch.wYear = 1970;
st_epoch.wMonth = 1;
st_epoch.wDay = 1;
SystemTimeToFileTime(&st_epoch, &ft_epoch);
GetSystemTimeAsFileTime(&ft_now);
GetSystemTimeAsFileTime(&time);
time_now = (DOUBLE)ft_now.dwHighDateTime/10000*UINT_MAX
+ (DOUBLE)ft_now.dwLowDateTime/10000;
time_epoch = (DOUBLE)ft_epoch.dwHighDateTime/10000*UINT_MAX
+ (DOUBLE)ft_epoch.dwLowDateTime/10000;
This is not correct, you need a <<32. Also there's no reason to use doubles for the computation, and you shouldn't have to use SystemTimeToFileTime for the epoch, it can be a constant.