Windows is not a real time operating system so it is not really able to reliably achieve high accuracy timing without using a device driver. The best I have been able to get is a few nanoseconds using QueryPerformanceCounter. This is the procedure I use:
var WaitCal: Int64;
procedure Wait(ns: Integer); var Counter, Freq, WaitUntil: Int64; begin if QueryPerformanceCounter(Counter) then begin QueryPerformanceFrequency(Freq); WaitUntil := Counter + WaitCal + (ns * (Freq div1000000)); while Counter < WaitUntil do QueryPerformanceCounter(Counter); end else Sleep(ns div1000); end;
To get improved accuracy do this a little while before using Wait()