i don't belive that there isn't timers with 1ms of precision, but i can't get any help. and i try search and nothing.
please can anyone give me something for start dooing a timer with 1ms of precision?
Printable View
i don't belive that there isn't timers with 1ms of precision, but i can't get any help. and i try search and nothing.
please can anyone give me something for start dooing a timer with 1ms of precision?
Not 100 % sure about 1 ms, but try multimedia timers
i found these function
CreateTimerQueueTimer() maybe i find 1 sample. but, please see my class:
why i don't get 100ms( or 10ms, at least)?Code:#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
#include <Mmsystem.h>
class Timer
{
private:
int MilliSecondsTimer;
private:
bool blnDestroyed;
private:
HANDLE Handle_Of_Thread_1;
typedef void (*MyTimerProc)();
MyTimerProc TimerProcedure;
static DWORD WINAPI StaticThreadProc(LPVOID param) {
static_cast<Timer*>(param)->MultithreadProcedure();
return 0;
}
public:
int SetMilliSeconds(int MilliSeconds)
{
MilliSecondsTimer = MilliSeconds;
return 0;
}
public:
int GetMilliSeconds()
{
return (MilliSecondsTimer);
}
private: void MultithreadProcedure()
{
/*LARGE_INTEGER liFrequency;
LARGE_INTEGER liStartTime;
LARGE_INTEGER liCurrentTime;
double a;
QueryPerformanceFrequency ( &liFrequency );
QueryPerformanceCounter ( &liStartTime );
for (;;)
{
QueryPerformanceCounter ( &liCurrentTime );
a=(int) ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart ));
if (a>=MilliSecondsTimer)
{
TimerProcedure();
QueryPerformanceCounter ( &liStartTime );
}
if (blnDestroyed==true) break;
}*/
int a=0;
for (;;)
{
if (blnDestroyed==true) break;
timeBeginPeriod(1) ;
Sleep(1) ;
timeEndPeriod(1);
a=a+1;
if (a ==MilliSecondsTimer)
{
TimerProcedure();
a=0;
}
}
CloseHandle(Handle_Of_Thread_1);
TerminateThread( Handle_Of_Thread_1,1);
}
public:
int Start(MyTimerProc TimerProc)
{
TimerProcedure = TimerProc;
Handle_Of_Thread_1=0;
CloseHandle(Handle_Of_Thread_1);
TerminateThread( Handle_Of_Thread_1,1);
blnDestroyed=false;
HANDLE hMyThread;
hMyThread = CreateThread(NULL, 0, StaticThreadProc, this, 0, NULL);
return 0;
}
public: int Destroy()
{
blnDestroyed=true;
return 0;
}
};
Timer test;
int a;
void TimerProcedure()
{
system("cls");
a=a+1;
printf("%d\n",a);
}
void main()
{
test.SetMilliSeconds(10);
test.Start(TimerProcedure);
getch();
test.Destroy();
}
anotherthing: i'm using VC++6, why CreateTimerQueueTimer() isn't in list?
how can i use it without a problems?
From MSDN October 2000:and perhaps you will need the latest SDK (from February 2003) compatible with VC++6.0Quote:
Requirements
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Use Google...
i don't test it, but i found here: http://wiki.tcl.tk/11970
thanks
i can't execute the exe on my windows7 and i can't extract manualy:(
Define "can't execute the exe"
BTW, could you install VC++6.0 on your windows7?
Edit this .bat file commenting out @echo off
Then open cmd window, change current directorz to the one where all your PSK files are and start this bat file.
What messages do you get?
BTW, you have to be an Admin to install anything!
ok.. installed and the VC++6 IDE have it on options. but it stills not in list the CreateTimerQueueTimer():(
Did you define the appropriate SDK Headers?
For Windows 200 it must be
_WIN32_WINNT >= 0x0500 and WINVER >= 0x0500