C# 獲取系統相關時間

sanyuni發表於2016-10-26

獲取系統時脈頻率

[DllImport("kernel32")]
static extern bool QueryPerformanceFrequency(ref long PerformanceFrequency);


獲取系統時鐘計數

 [DllImport("kernel32.dll ")]
 static extern bool QueryPerformanceCounter(ref long lpPerformanceCount);

獲取精確時間

 [DllImport("kernel32.dll")]  //100ns 精度
 public static extern void GetSystemTimeAsFileTime(out System.Runtime.InteropServices.ComTypes.FILETIME lpSystemTimeAsFileTime);

long a = (((long)lpSystemTimeAsFileTime.dwHighDateTime) << 32) | ((uint)lpSystemTimeAsFileTime.dwLowDateTime);

其它相關參考:http://www.cnblogs.com/kex1n/p/3297607.html
http://www.cnblogs.com/sifenkesi/archive/2011/06/01/2065673.html

相關文章