The OpenEvent function returns a handle to an existing named event object.
HANDLE OpenEvent(
DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // inherit flag
LPCTSTR lpName // pointer to event-object name
);
This parameter can be any combination of the following values:
Access | Description |
---|---|
EVENT_ALL_ACCESS | Specifies all possible access flags for the event object. |
EVENT_MODIFY_STATE | Enables use of the event handle in the SetEvent and ResetEvent functions to modify the event's state. |
SYNCHRONIZE | Windows NT: Enables use of the event handle in any of the wait functions to wait for the event's state to be signaled. |
If the function succeeds, the return value is a handle to the event object.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
The OpenEvent function enables multiple processes to open handles of the same event object. The function succeeds only if some process has already created the event by using the CreateEvent function. The calling process can use the returned handle in any function that requires a handle to an event object, subject to the limitations of the access specified in the dwDesiredAccess parameter.
The handle can be duplicated by using the DuplicateHandle 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 has been closed.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Synchronization Overview, Synchronization Functions, CloseHandle, CreateEvent, CreateProcess, DuplicateHandle, PulseEvent, ResetEvent, SetEvent