I'm able to create two timers with Visual Studio / Win XP, so there may be an issue with your setup. This example is based on old code.
Code:
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "winmm.lib") /* include winmm.lib */
/*----------------------------------------------------------------------*/
/* data */
/*----------------------------------------------------------------------*/
static TIMECAPS sTimeCaps; /* min and max timer values */
static MMRESULT mmTimerId0; /* timer id */
static MMRESULT mmTimerId1; /* timer id */
static volatile DWORD dwTicks0; /* tick counter */
static volatile DWORD dwTicks1; /* tick counter */
/*----------------------------------------------------------------------*/
/* code */
/*----------------------------------------------------------------------*/
void CALLBACK TimerFunction0(UINT, UINT, DWORD, DWORD, DWORD);
void CALLBACK TimerFunction1(UINT, UINT, DWORD, DWORD, DWORD);
/*----------------------------------------------------------------------*/
/* main */
/*----------------------------------------------------------------------*/
int main(int argc, char **argv)
{
/* ** get min and max period */
timeGetDevCaps(&sTimeCaps, sizeof(sTimeCaps));
if(sTimeCaps.wPeriodMin != 1){
printf("1 ms resolution not allowed\n");
goto exit1;}
timeBeginPeriod(1); /* set period to 1ms */
Sleep(128); /* wait for it to stabilize */
/* ** create two 4ms timers */
mmTimerId0 = timeSetEvent(4, 0, TimerFunction0, 0, TIME_PERIODIC);
if(mmTimerId0 == (MMRESULT)0){
printf("Failed to generate multimedia timer 0.\n");
goto exit0;}
Sleep(2);
mmTimerId1 = timeSetEvent(4, 0, TimerFunction1, 0, TIME_PERIODIC);
if(mmTimerId1 == (MMRESULT)0){
printf("Failed to generate multimedia timer 1.\n");
goto exit0;}
Sleep(2048); /* wait 2.048 seconds */
exit0:
if(mmTimerId0)
timeKillEvent(mmTimerId0);
if(mmTimerId1)
timeKillEvent(mmTimerId1);
timeEndPeriod(1); /* restore resolution to default */
printf("dwTicks0 %d\n", dwTicks0);
printf("dwTicks1 %d\n", dwTicks1);
exit1:
return(0);
}
/*----------------------------------------------------------------------*/
/* TimerFunction increments dwTicks */
/*----------------------------------------------------------------------*/
void CALLBACK TimerFunction0(UINT uTimerID, UINT uMsg,
DWORD dwUser, DWORD dw1, DWORD dw2)
{
dwTicks0 += 1; /* increment ticks */
}
/*----------------------------------------------------------------------*/
/* TimerFunction increments dwTicks */
/*----------------------------------------------------------------------*/
void CALLBACK TimerFunction1(UINT uTimerID, UINT uMsg,
DWORD dwUser, DWORD dw1, DWORD dw2)
{
dwTicks1 += 1; /* increment ticks */
}