Yeah, you can print the current resolution and the allowable ranges with this
Code:
// a rare sighting of the mythical timeGetPeriod
void PrintCurrentTimerResolutions()
{
// reutrn should be NTSTATUS but the typedef isn't in windows.h or ntstatus.h (go figure)
// adding winternl.h or ntsecapi.h solely for it is overkill
typedef long (NTAPI*pfnNtQueryTimerResolution)(PULONG pMaxRes, PULONG pMinRes, PULONG pCurRes);
HMODULE hNtDll = GetModuleHandleW(L"ntdll.dll");
pfnNtQueryTimerResolution ntQueryTimerResolution =
(pfnNtQueryTimerResolution)GetProcAddress(hNtDll, "NtQueryTimerResolution");
// 100-nanosecond units in 1 MS
static const ULONG REFTIMES_PER_MILLISEC = 10000;
if(ntQueryTimerResolution)
{
ULONG curRes = 0, minRes = 0, maxRes = 0;
ntQueryTimerResolution(&maxRes, &minRes, &curRes);
printf(
"Max res: %lu, ms: %lu\nMin res: %lu, ms: %lu\nCur res: %lu, ms: %lu\n",
maxRes, maxRes / REFTIMES_PER_MILLISEC,
minRes, minRes / REFTIMES_PER_MILLISEC,
curRes, curRes / REFTIMES_PER_MILLISEC
);
}
}
The test above was done with results of
Max res: 156001, ms: 15
Min res: 5000, ms: 0
Cur res: 10000, ms: 1
I reran it on a 7x64 VM with timer results of
Max res: 156250, ms: 15
Min res: 5000, ms: 0
Cur res: 156250, ms: 15
and the bottom line was "late by on average 16 milliseconds". The takeaway is 'as late as the clock' which is logical. The other would seem to be you can set the period to <1ms but not via any Microsoft documented functions.