Return to Snippet

Revision: 701
at August 1, 2006 01:52 by igamojp


Initial Code
/**
 * Multimedia Timer
 *
 * Timer Interrupttion per interval[ms]
 */

#include<windows.h> 
#include<mmsystem.h>

#pragma comment(lib, "winmm.lib")

void CALLBACK TimeProc(UINT uTimerID, UINT uMsg,
                        DWORD dwUser, DWORD dw1, DWORD dw2)
{
  /**
   * Timer Interruption
   */
}

void main()
{
    UINT uDelay = 1000;
    UINT uResolution = 1;
    DWORD dwUser = NULL;
    UINT fuEvent = TIME_PERIODIC; //You also choose TIME_ONESHOT;

    MMRESULT FTimerID;
    timeBeginPeriod(1);
    FTimerID = timeSetEvent(uDelay, uResolution, TimeProc, dwUser, fuEvent);
    if(FTimerID==NULL){
        printf("Failed to generate multimedia timer.\n");
    }

    Sleep(10000);

    timeKillEvent(FTimerID);
    timeEndPeriod(1);
}

Initial URL

                                

Initial Description

                                

Initial Title
Multimedia Timer

Initial Tags

                                

Initial Language
C++