March 20th, 2013, 05:54 AM
#1
timers with 1ms of precision
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?
March 20th, 2013, 07:44 AM
#2
Re: timers with 1ms of precision
Not 100 % sure about 1 ms, but try multimedia timers
Victor Nijegorodov
March 20th, 2013, 07:50 AM
#3
Re: timers with 1ms of precision
Originally Posted by
VictorN
i found these function
CreateTimerQueueTimer() maybe i find 1 sample. but, please see my class:
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();
}
why i don't get 100ms( or 10ms, at least)?
March 20th, 2013, 08:00 AM
#4
Re: timers with 1ms of precision
Victor Nijegorodov
March 20th, 2013, 08:02 AM
#5
Re: timers with 1ms of precision
anotherthing: i'm using VC++6, why CreateTimerQueueTimer() isn't in list?
how can i use it without a problems?
March 20th, 2013, 08:07 AM
#6
Re: timers with 1ms of precision
From MSDN October 2000:
Requirements
Windows NT/2000 : Requires Windows 2000.
Windows 95/98 : Unsupported.
Header : Declared in Winbase.h; include Windows.h.
Library : Use Kernel32.lib.
and perhaps you will need the latest SDK (from February 2003) compatible with VC++6.0
Victor Nijegorodov
March 20th, 2013, 08:08 AM
#7
Re: timers with 1ms of precision
Originally Posted by
VictorN
From MSDN October 2000:and perhaps you will need the latest SDK (from February 2003) compatible with VC++6.0
sorry where i get that?
March 20th, 2013, 08:09 AM
#8
Re: timers with 1ms of precision
Victor Nijegorodov
March 20th, 2013, 08:17 AM
#9
Re: timers with 1ms of precision
Originally Posted by
VictorN
Use Google...
i don't test it, but i found here: http://wiki.tcl.tk/11970
thanks
March 20th, 2013, 08:21 AM
#10
Re: timers with 1ms of precision
Originally Posted by
Cambalinho
it looks promising!
Victor Nijegorodov
March 20th, 2013, 09:20 AM
#11
Re: timers with 1ms of precision
i can't execute the exe on my windows7 and i can't extract manualy
March 20th, 2013, 09:27 AM
#12
Re: timers with 1ms of precision
Define "can't execute the exe"
BTW, could you install VC++6.0 on your windows7?
Victor Nijegorodov
March 20th, 2013, 09:31 AM
#13
Re: timers with 1ms of precision
Originally Posted by
VictorN
Define "can't execute the exe"
BTW, could you install VC++6.0 on your windows7?
"Define "can't execute the exe""
just open the window and then close it.
"BTW, could you install VC++6.0 on your windows7?"
yes i could and was easy. but i install the Visual Studio 98(and better install SP6 for correct the errors).
March 20th, 2013, 09:40 AM
#14
Re: timers with 1ms of precision
Originally Posted by
Cambalinho
"Define "can't execute the exe""
just open the window and then close it.
But why do you execute it directly?
You have to start the PSDK-FULL.bat file!
Victor Nijegorodov
March 20th, 2013, 09:43 AM
#15
Re: timers with 1ms of precision
Originally Posted by
VictorN
But why do you execute it directly?
You have to start the PSDK-FULL.bat file!
the resolte is the same
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks