The timeSetEvent function starts a specified timer event. The multimedia timer runs in its own thread. After the event is activated, it calls the specified callback function or sets or pulses the specified event object.
这个函数以一个指定的“时间事件”为开始,当这个事件被触发后,他会一毫秒为单位,触发他的自己的线程(他的回调函数或者是加入特定是时间对象)
MMRESULT timeSetEvent( UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD dwUser, UINT fuEvent );
Event delay, in milliseconds. If this value is not in the range of the minimum and maximum event delays supported by the timer, the function returns an error.
事件延时时间,以毫秒为单位。他的值必须在最大和最小值之间,否则会失败。
Resolution of the timer event, in milliseconds. The resolution increases with smaller values; a resolution of 0 indicates periodic events should occur with the greatest possible accuracy. To reduce system overhead, however, you should use the maximum value appropriate for your application.
User-supplied callback data.
要传送给回调函数来使用
Value | Meaning |
---|---|
TIME_ONESHOT | Event occurs once, after uDelay milliseconds. |
TIME_PERIODIC | Event occurs every uDelay milliseconds. |
The fuEvent parameter may also include one of the following values.
Value | Meaning |
---|---|
TIME_CALLBACK_FUNCTION | When the timer expires, Windows calls the function pointed to by the lpTimeProc parameter. This is the default. |
TIME_CALLBACK_EVENT_SET | When the timer expires, Windows calls the SetEvent function to set the event pointed to by the lpTimeProc parameter. The dwUser parameter is ignored. |
TIME_CALLBACK_EVENT_PULSE | When the timer expires, Windows calls the PulseEvent function to pulse the event pointed to by the lpTimeProc parameter. The dwUser parameter is ignored. |
Returns an identifier for the timer event if successful or an error otherwise. This function returns NULL if it fails and the timer event was not created. (This identifier is also passed to the callback function.)
Each call to timeSetEvent for periodic timer events requires a corresponding call to the timeKillEvent function.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Mmsystem.h.
Library: Use Winmm.lib.