I know a function ,SetTimer() ,can do the same job with Multimedia Timer. But SetTimer() is low prioioty and not accurate enough that I want. So, i choose Multimedia Timer . I readed the usage of Multimedia Timer in the MSDN. And then i use it in my code. No double,some error occur,and i don not know how to resolve it. Problem is on :
UINT TimerID = timeSetEvent(100, 0, (LPTIMECALLBACK)TimerProc, 0,TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
The third parameter is Callback function which is called when timer is expired. And Callback function i define :
void CALLBACK TimerProc(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
Everything i do is the same with MSDN or guidance of internet ,but when i compile it,he always say the third parameter of timeSetEvent() can not transform to LPTIMECALLBACK even i replace(LPTIMECALLBACK)TimerProc with TimerProc ,the situation is the same. Sure i have writed :
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
on my code, but he just failure. So ,i need someone's help or you have another method to do the same job excepted SetTimer().
PS: My Development Enviroment is Visual Studio .NET 2002

About:『Multimedia Timer』 Problem
Michael Creamer
Is your callback a class member function Is the method declared as __stdcall (or CALLBACK)
LynnOoi
All I did was to create a normal console application and pasted your data in.
mmsystem.h is include in windows.h if WIN32_LEAN_AND_MEAN is not defined. Look in windows.h, the best way is to include windows.h in your file, right-click it an select "Open Document <windows.h>". I'm suprised that you didn't get any other errors because of not including windows.h.
Try changing DWORD to DWORD_PTR, just in case it requires the exact signiture.
If you think it could be the pragma, remove it and add the winmm.lib declaration in the projects linker "Additional dependencies" property.
S!ava
I use windows.h in my code , and it still didn't work. it's wizardly. Now i have some question want to check with you. First, needn't you include <mmsystem.h> in your code if i don't do this, the compiler will say NO. Second, winmm.lib except write in the code, do i need do anything to "Real" include it in my code ( do you understand what i mean ) OK. this two point is what i want to know . Especially point two, if it isn't different between you and me, then i think i shoud upgrade my VS .NET 2002 .
Anjana Mazumder MSFT
I'm using VS.net 2003, and I have exactly the same problem like you, I doubt it's because the managed extention, I tried to convert the samples online from unmaged to managed, but never got it so far.
Even I tried Bad Habit's recommendations....still no clue....
error C2664: 'timeSetEvent' : cannot convert parameter 3 from 'void (UINT,UINT,DWORD_PTR,DWORD_PTR,DWORD_PTR)' to 'LPTIMECALLBACK'
Any help is greatly appreciated.
Gary7
#include
"stdafx.h"#include <windows.h>
#pragma comment(lib, "Winmm.lib")
void
CALLBACK TimerProc(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2){
}
int
_tmain(int argc, _TCHAR* argv[]){
UINT TimerID = timeSetEvent(100, 0, TimerProc, 0, TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
return 0;
}
I basically cut and pasted your code, but had to use windows.h because of the other definitions.
The only other difference is I'm using VS.NET 2003