1. 程式人生 > >C# 獲取系統相關時間

C# 獲取系統相關時間

獲取系統時鐘頻率

[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);