The CreateWaitableTimer function creates a “waitable” timer object.
HANDLE CreateWaitableTimer(
LPSECURITY_ATTRIBUTES lpTimerAttributes, |
// pointer to security attributes |
BOOL bManualReset, |
// flag for manual reset state |
LPCTSTR lpTimerName |
// pointer to timer object name |
); |
|
If the string specified in the lpTimerName parameter matches the name of an existing named timer object, the call returns successfully and the GetLastError function returns ERROR_ALREADY_EXISTS.
If lpTimerName is NULL, the timer object is created without a name.
If lpTimerName matches the name of an existing event, semaphore, mutex, or file-mapping object, the function fails and GetLastError returns ERROR_INVALID_HANDLE. This occurs because event, semaphore, mutex, file-mapping, and waitable-timer objects share the same name space.
If the function succeeds, the return value is a handle to the timer object. If the named timer object exists before the function call, GetLastError returns ERROR_ALREADY_EXISTS. Otherwise, GetLastError returns zero.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
The handle returned by CreateWaitableTimer is created with the TIMER_ALL_ACCESS access right. This handle can be used in any function that requires a handle to a timer object.
Any thread of the calling process can specify the timer object handle in a call to one of the wait functions.
Multiple processes can have handles to the same timer object, enabling use of the object for interprocess synchronization.
Use the CloseHandle function to close the handle. The system closes the handle automatically when the process terminates. The timer object is destroyed when its last handle has been closed.
CancelWaitableTimer, CloseHandle, CreateProcess, DuplicateHandle, FILETIME, OpenWaitableTimer, SECURITY_ATTRIBUTES, SetWaitableTimer