Last active
July 5, 2022 17:40
-
-
Save QuiltMeow/0a30868a69d86ee92110161986d6a37f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
namespace ClockResolution | |
{ | |
public struct TimerResolution | |
{ | |
public double periodMin; | |
public double periodMax; | |
public double periodCurrent; | |
} | |
public static class WindowsAPI | |
{ | |
[DllImport("ntdll.dll", SetLastError = true)] | |
private static extern int NtQueryTimerResolution(out uint MaximumResolution, out uint MinimumResolution, out uint CurrentResolution); | |
public static TimerResolution queryTimerResolution() | |
{ | |
NtQueryTimerResolution(out uint max, out uint min, out uint current); | |
return new TimerResolution() | |
{ | |
periodMin = min / 10000D, | |
periodMax = max / 10000D, | |
periodCurrent = current / 10000D | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment