1 2 #define WIN32_LEAN_AND_MEAN 3 #include <windows.h> 4 #include <time.h> 5 6 #include "gettimeofday.h" 7 gettimeofday(struct timeval * tv,struct timezone * tz)8int gettimeofday(struct timeval *tv, struct timezone *tz) 9 { 10 FILETIME ft; 11 LARGE_INTEGER li; 12 __int64 t; 13 static int tzflag; 14 15 if(tv) 16 { 17 GetSystemTimeAsFileTime(&ft); 18 li.LowPart = ft.dwLowDateTime; 19 li.HighPart = ft.dwHighDateTime; 20 t = li.QuadPart; 21 t -= EPOCHFILETIME; 22 t /= 10; 23 tv->tv_sec = (long)(t / 1000000); 24 tv->tv_usec = (long)(t % 1000000); 25 } 26 27 if (tz) 28 { 29 if (!tzflag) 30 { 31 _tzset(); 32 tzflag++; 33 } 34 tz->tz_minuteswest = _timezone / 60; 35 tz->tz_dsttime = _daylight; 36 } 37 38 return 0; 39 } 40