It might be obvious, but I can't find/google the correct method to get the current system value of the timer resolution, which a program can set by timeBeginPeriod(n)/timeEndPeriod(n). I want to find out what's the current resolution... The Windows 7 default value seems to be 15.6 ms, but other applications or the machine vendor might have changed the setting.
There are some tools which report the value, but I need to read the value in an application.
Thanks for any quick hint or link. C# would be a plus, but I know my way around with P/Invoke.
EDIT: Thanks to the answer I've made a little tool in C# which uses the described method: github.com/tebjan/TimerTool
Windows timer resolution is provided by the hidden API call:
NTSTATUS NtQueryTimerResolution(OUT PULONG MinimumResolution,
OUT PULONG MaximumResolution,
OUT PULONG ActualResolution);
NtQueryTimerResolution
is exported by the native Windows NT library NTDLL.DLL.
Common hardware platforms report 156,250 or 100,144 for ActualResolution; older platforms may report even larger numbers; newer systems, particulary when HPET (High Precision Event Timer) or constant/invariant TSC are supported, may return 156,001 for ActualResolution.
Calls to timeBeginPeriod(n)
are reflected in ActualResolution.
More details in this answer.