CreateEvent (Compact 2013)
3/28/2014
This function creates a named or unnamed event object.
Syntax
HANDLE CreateEvent(
LPSECURITY_ATTRIBUTES
lpEventAttributes,
BOOL bManualReset,
BOOL bInitialState,
LPTSTR lpName
);
Parameters
- lpEventAttributes
[in] Ignored. Must be NULL.
- bManualReset
[in] Boolean value that specifies whether a manual-reset or auto-reset event object is created. If true, you must use the ResetEvent function to manually reset the state to nonsignaled. If false, the system automatically resets the state to nonsignaled after a single waiting thread is released.
- bInitialState
[in] Boolean value that specifies the initial state of the event object. If true, the initial state is signaled; otherwise, it is nonsignaled.
lpName
[in] Pointer to a null-terminated string that specifies the name of the event object. The name is limited to MAX_PATH characters and can contain any character except the backslash path-separator character (\). Name comparison is case sensitive.If lpName matches the name of an existing named event object, the bManualReset and bInitialState parameters are ignored because they have already been set by the creation process.
If lpName is NULL, the event object is created without a name.
Each object type, such as memory maps, semaphore objects, events, message queues, mutexes, and watchdog timers, has its own separate namespace. Empty strings, "", are handled as named objects. On Windows desktop-based platforms, synchronization objects all share the same namespace.
Return Value
A handle to the event object indicates success. NULL indicates failure. To get extended error information, call GetLastError.
Remarks
The handle that CreateEvent returns has EVENT_ALL_ACCESS access to the new event object, and can be used in any function that requires a handle to an event object.
Any thread of the calling process can specify the event-object handle in a call to one of the wait functions. The single-object wait functions return when the state of the specified object is signaled. The multiple-object wait functions can be instructed to return when any one of the specified objects is signaled. When a wait function returns, the waiting thread is released to continue its execution.
The event object's initial state is specified by the bInitialState parameter. Use the SetEvent function to set the state of an event object to signaled. Use the ResetEvent function to reset the state of an event object to nonsignaled.
When the state of a manual-reset event object is signaled, it remains signaled until it is explicitly reset to nonsignaled by the ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait operations for the specified event object, can be released while the object's state is signaled.
When the state of an auto-reset event object is signaled, it remains signaled until a single waiting thread is released; the system then automatically resets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled.
Multiple processes can have handles of the same event object, enabling use of the object for interprocess synchronization. The following object-sharing mechanism is available: a process can specify the name of an event object in a call to the CreateEvent function.
Use the CloseHandle function to close the handle. The system closes the handle automatically when the process terminates. The event object is destroyed when its last handle is closed.
The following code example creates a new event object, with an initial state of signaled, that the system automatically resets.
HANDLE CreateEvent(Null, False, False, PointerName);
Note
Do not put protected information into the names of kernel objects such as events, semaphores, mutexes, or memory-mapped files because CeLog writes these to its log. A malicious user could collect this information from the log.
Note
Do not take a pointer from a caller and use it as the name of a kernel object without first using access-checking APIs such as CeOpenCallerBuffer, which are designed to prevent callers from reading system data.
Requirements
Header |
winbase.h |
Library |
coredll.lib, |
See Also
Reference
Synchronization Functions
OpenEvent
SetEventData
WaitForSingleObject