如何确定当前的 Windows 计时器分辨率? [英] How to determine the current Windows timer resolution?
问题描述
这可能很明显,但我无法找到/google 获取计时器分辨率的当前系统值的正确方法,程序可以通过 timeBeginPeriod(n)/timeEndPeriod(n) 设置该值.我想知道当前的分辨率是多少... Windows 7 默认值似乎是 15.6 毫秒,但其他应用程序或机器供应商可能已更改设置.
有一些工具可以报告该值,但我需要在应用程序中读取该值.
感谢您提供任何快速提示或链接.C# 会是一个加分项,但我知道如何使用 答案中有更多细节.
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 PULONGMinimumResolution,
OUT LONGMaximumResolution,
OUT PULONGActualResolution);
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.
这篇关于如何确定当前的 Windows 计时器分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!