1. The utility uses the function
to get the intervals. And, as expected,
can change the interval.
2. Using very high priorities is a very bad idea. You can lock your complete system. You may use
to measure time spans with higher resolutions. There are some articles here at CodeProject about the Performance Counter.
3. If you only want to measure times, using
may solve your problem. If you need some kind of action after a specific very short time, things are more complicated.
I must correct my answer to the first item.
can be only used to get the current timer interval and
can't be used to set it. To get also the min. and max. values and change the interval, the undocumented functions
can be used. These functions have no associated import library. Use
to dynamically link to Ntdll.dll
can be used rather than
has been loaded by the app:
typedef NTSTATUS (CALLBACK* LPFN_NtQueryTimerResolution)(PULONG,PULONG,PULONG);
typedef NTSTATUS (CALLBACK* LPFN_NtSetTimerResolution)(ULONG,BOOLEAN,PULONG);
HMODULE hNtDll = ::GetModuleHandle(_T("Ntdll"));
ULONG nMinRes, nMaxRes, nCurRes;
LPFN_NtQueryTimerResolution pQueryResolution =
if (pQueryResolution &&
pQueryResolution(&nMinRes, &nMaxRes, &nCurRes) == STATUS_SUCCESS)
TRACE(_T("NT timer resolutions (min/max/cur): %u.%u / %u.%u / %u.%u ms"),
nMinRes / 10000, (nMinRes % 10000) / 10,
nMaxRes / 10000, (nMaxRes % 10000) / 10,
nCurRes / 10000, (nCurRes % 10000) / 10);
LPFN_NtSetTimerResolution pSetResolution =
if (pSetResolution && nSetRes)
NTSTATUS nStatus = pSetResolution(nSetRes, TRUE, &nCurRes);