How to Programm Timer with high resolution (not system timer)
less 5 ms.
How to Programm Timer with high resolution (not system timer)
less 5 ms.
Last edited by GNick; 04-05-2002 at 07:02 AM.
Read the system time, store that, then keep on reading it comparing with the original until the elapsed time required has happened?
Outrageously crude and inefficient but best I can offer with so little to go on.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Get a copy of the DDK and do it through interupts.
Slightly less crude but still inefficant.
[edit]
oh and I forgot to mention difficult and not worth the effort
[/edit]
Last edited by shtarker; 04-05-2002 at 05:57 AM.
If you own a piece of land and there is an volcano on it and it ruins a
nearby town, do you have to pay for the property damage?
High performance timer you say? Try these, QueryPerformanceCounter and you will need QueryPerformanceFrequency to see if it's supported and if so what the frequency is. Look it up on MSDN, I think this is what you were looking for.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
Perhaps you can use SetTimer to create a timer. The time-out value is in milliseconds.
Code:UINT SetTimer ( HWND hWnd, // handle of window for timer messages UINT nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc // address of timer procedure );
It depends how accurate you want it....if you want it to be roughly x milliseconds then SetTimer and the like will be ok......but if you want more accuracy it can be much harder (depending on the accuracy you want)
Last edited by Fordy; 04-06-2002 at 03:16 AM.
And lying roughly in the middle in the 'accuracy stakes is the multimedia timer which you can get a 'time' with the timeGetTime fn. #include <mmsystem.h> and link with winmm.lib (msvc, borland, lcc-win32) or libwinmm.a (MinGW; can also use '-lwinmm').
He said he didn't want to use a system timer.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
If you dont want a system timer then dont post on the Windows board since this is for "Windows System Proramming!"
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein
>>He said he didn't want to use a system timer.<<
Major ooops! experience. One day i'll get this skim-reading right.
Sorry for any confusion I may have caused.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.