In embedded systems using C++, that's often easily done. In Windows, however, it's not. :(
This is because those embedded systems are designed to run on very selected hardware and therefore the operating system has a deep knowledge of the behaviour of the hardware,
including the latencies
. This enables the Operating system to provide
very high precision timer facility. However, the fact is that the operating system will run ONLY on that specific hardware. Such operating systems are called RTOS (Real-Time Operating System).
However, Windows was designed to run on many, many different types of hardware. Clearly, one hardware will be different from the other in numerous ways and there's no way Windows will have intimate knowledge of every type of hardware. This leads to Windows not being able to give you such high precision timer like an RTOS will do.
You might try the following, but remember that the closest you'd get to would be something like 15 to 20 milliseconds (+/- a few milliseconds, depending on your hardware):
QueryPerformanceCounter()
: This function will return a time count that's very precise, but because Windows isn't a real-time operating system, sometimes the counts won't make sense. I understand that the count can even seem to go backwards in some situations!- Multimedia Timer functions: I've never used these, only heard about them. I understand that they work somewhat more reliably than
QueryPerformanceCounter()
, but they too have limitations.