KillTimer

This function destroys the specified timer. The system searches the message queue for any pending WM_TIMER messages associated with the timer and removes them.

BOOL KillTimer(
  HWND hWnd, 
  UINT uIDEvent 
); 

Parameters

  • hWnd
    Handle to the window associated with the specified timer. This value must be the same as the hWnd value passed to the SetTimer function that created the timer.
  • uIDEvent
    Specifies the identifier of the timer to be destroyed. If the window handle passed to SetTimer is valid, this parameter must be the same as the uIDEvent value passed to SetTimer. If the application calls SetTimer with hWnd set to NULL, this parameter must be the timer identifier returned by SetTimer.

Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

After the timer terminates, you will not get WM_TIMER messages regardless of whether the timer has fired.

The timers are kept in a list on the message queue. If there are no other higher priority posted messages, the list is searched for timers that have fired. If a timer has fired a WM_TIMER message is returned in GetMessage. When KillTimer is called, the timer is removed from the list immediately. The next time GetMessage is called it will be impossible to get a WM_TIMER message from the timer because it is no longer in the message queue's list of timers.

If the uElapse parameter of the SetTimer function is set to INFINITE, KillTimer fails to destroy the timer.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.

See Also

SetTimer | WM_TIMER | GetMessage

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.