C# 获取系统相关时间

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/SANYUNI/article/details/52937273

获取系统时钟频率

[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

猜你喜欢

转载自blog.csdn.net/SANYUNI/article/details/52937273