Canceling a Timer Event

[The feature associated with this page, Multimedia Timers, is a legacy feature. It has been superseded by Multimedia Class Scheduler Service. Multimedia Class Scheduler Service has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Multimedia Class Scheduler Service instead of Multimedia Timers, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

Note

This topic describes an obsolete function. New applications should use the CreateTimerQueueTimer function to create timers.

 

For every periodic timer creating by calling timeSetEvent, the application must cancel the timer by calling the timeKillEvent function before it frees the memory that contains the callback function. To cancel a timer event, it might call the following function.

void DestroyTimer(NPSEQ npSeq)
{
    if(npSeq->wTimerID) {                // is timer event pending?
        timeKillEvent(npSeq->wTimerID);  // cancel the event
        npSeq->wTimerID = 0;
    }
} 

Using Multimedia Timers