CreateWaitableTimerExW function (synchapi.h)
Creates or opens a waitable timer object and returns a handle to the object.
Syntax
HANDLE CreateWaitableTimerExW(
[in, optional] LPSECURITY_ATTRIBUTES lpTimerAttributes,
[in, optional] LPCWSTR lpTimerName,
[in] DWORD dwFlags,
[in] DWORD dwDesiredAccess
);
Parameters
[in, optional] lpTimerAttributes
A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL, the timer handle cannot be inherited by child processes.
If lpTimerAttributes is NULL, the timer object gets a default security descriptor and the handle cannot be inherited. The ACLs in the default security descriptor for a timer come from the primary or impersonation token of the creator.
[in, optional] lpTimerName
The name of the timer object. The name is limited to MAX_PATH characters. Name comparison is case sensitive.
If lpTimerName is NULL, the timer object is created without a name.
If lpTimerName matches the name of an existing event, semaphore, mutex, job, or file-mapping object, the function fails and GetLastError returns ERROR_INVALID_HANDLE. This occurs because these objects share the same namespace.
The name can have a "Global" or "Local" prefix to explicitly create the object in the global or session namespace. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Namespaces. Fast user switching is implemented using Terminal Services sessions. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users.
The object can be created in a private namespace. For more information, see Object Namespaces.
[in] dwFlags
This parameter can be 0 or the following values.
[in] dwDesiredAccess
The access mask for the timer object. For a list of access rights, see Synchronization Object Security and Access Rights.
Return value
If the function succeeds, the return value is a handle to the timer object. If the named timer object exists before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
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.
- A process created by the CreateProcess function can inherit a handle to a timer object if the lpTimerAttributes parameter of CreateWaitableTimerEx enables inheritance.
- A process can specify the timer object handle in a call to the DuplicateHandle function. The resulting handle can be used by another process.
- A process can specify the name of a timer object in a call to the OpenWaitableTimer or CreateWaitableTimerEx function.
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.
To associate a timer with a window, use the SetTimer function.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | synchapi.h (include Windows.h) |
Library | Kernel32.lib |
DLL | Kernel32.dll |