Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

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

Syntax

BOOL KillTimer(
  HWND 
hWnd, 
  UINT 
uIDEvent 
); 

Parameters

hWnd

[in] Handle to the window associated with the specified timer. This value must be the same as the hWndvalue passed to the SetTimerfunction that created the timer.

uIDEvent

[in] Specifies the identifier of the timer to be destroyed. If the window handle passed to SetTimeris valid, this parameter must be the same as the uIDEventvalue passed to SetTimer. If the application calls SetTimerwith hWndset to NULL, this parameter must be the timer identifier returned by SetTimer.

Return Value

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 KillTimeris called, the timer is removed from the list immediately. The next time GetMessageis 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 uElapseparameter of the SetTimerfunction is set to INFINITE, KillTimerfails to destroy the timer.

Requirements

Header winbase.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also