次の方法で共有


timeSetEvent (Compact 2013)

3/26/2014

This function starts a specified timer event.

Syntax

MMRESULT timeSetEvent(
  UINT uDelay,
  UINT uResolution,
  LPTIMECALLBACK fptc,
  DWORD dwUser,
  UINT fuEvent
);

Parameters

  • uDelay
    [in] 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.

  • uResolution
    [in] Resolution of the timer event, in milliseconds.

    The resolution increases with smaller values; a resolution of zero 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.

  • fptc
    [in] Pointer to a callback function that is called once on expiration of a single event or periodically on expiration of periodic events.

    If fuEvent specifies the TIME_CALLBACK_EVENT_SET or TIME_CALLBACK_EVENT_PULSE flag, and then the fptc parameter is interpreted as a handle to an event object. The event will be set or pulsed on completion of a single event or periodically on completion of periodic events.

    For any other value of fuEvent, the fptc parameter is interpreted as a function pointer.

    The following code example shows the signature for the function pointer.

    typedef void (CALLBACK TIMECALLBACK)(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);

    typedef TIMECALLBACK FAR *LPTIMECALLBACK;

  • dwUser
    [in] User-supplied callback data.
  • fuEvent
    [in] Timer event type.

    The following table shows the values that can be included by the fuEvent parameter.

    Value

    Description

    TIME_ONESHOT

    Event occurs once, after uDelay milliseconds.

    TIME_PERIODIC

    Event occurs every uDelay milliseconds.

    TIME_CALLBACK_FUNCTION

    When the timer expires, the system calls the function pointed to by the fptc parameter.

    This is the default value.

    TIME_CALLBACK_EVENT_SET

    When the timer expires, the system calls the SetEvent function to set the event pointed to by the fptc parameter.

    The dwUser parameter is ignored.

    TIME_CALLBACK_EVENT_PULSE

    When the timer expires, the system calls PulseEvent function to pulse the event pointed to by the fptc parameter.

    The dwUser parameter is ignored.

Return Value

Returns an identifier for the timer event, if successful; otherwise, an error is returned.

This function returns 0 if it fails and the timer event was not created.

This identifier is passed to the callback function.

Remarks

Each call to timeSetEvent for periodic timer events requires a corresponding call to the timeKillEvent function.

Creating an event with the TIME_CALLBACK_FUNCTION flags prevents the event from occurring after the timeKillEvent function is called.

Requirements

Header

mmsystem.h

Library

Mmtimer.lib

See Also

Reference

Timer Driver Functions
timeKillEvent

Other Resources

SetEvent
PulseEvent
Time Reference