标签:return window time mil pre desktop mtime stdio.h pps
#include "windows.h" #include "stdio.h" #include "inttypes.h" int main() { FILETIME flt; SYSTEMTIME st, lot; __int64 wintime; __int64 seconds; __int64 nano_seconds; int milliseconds; int microsecond; // Windows 2000 Professional [desktop apps | UWP apps] GetSystemTimeAsFileTime((FILETIME*)&wintime); // Windows 8 [desktop apps | UWP apps] //GetSystemTimePreciseAsFileTime((FILETIME*)&wintime); wintime -=116444736000000000; seconds = wintime / 10000000; nano_seconds = wintime % 10000000 * 100; milliseconds = nano_seconds / 1000000; microsecond = (nano_seconds - milliseconds * 1000000)/100; //printf("The file time is: seconds %lld nano-seconds %lld milliseconds %d %ld\n", // seconds, nano_seconds, milliseconds, microsecond); FileTimeToSystemTime((FILETIME*)&wintime, &st); FileTimeToLocalFileTime((FILETIME*)&wintime, &flt); FileTimeToSystemTime(&flt, &lot); printf("The system time is: %02d:%02d:%02d.%03d.%04d \n", st.wHour, st.wMinute , st.wSecond, milliseconds, microsecond); printf("The local time is: %02d:%02d:%02d.%03d.%04d \n", lot.wHour, lot.wMinute , lot.wSecond, milliseconds, microsecond); return 0; } 输出 The system time is: 13:08:30.045.2907 The local time is: 21:08:30.045.2907
标签:return window time mil pre desktop mtime stdio.h pps
原文地址:http://www.cnblogs.com/nlsoft/p/7944460.html