# Function Reference

# _WinAPI_CreateEvent

Creates or opens a named or unnamed event object

#include <WinAPIProc.au3>
_WinAPI_CreateEvent ( [$tAttributes = 0 [, $bManualReset = True [, $bInitialState = True [, $sName = ""]]]] )

## Parameters

$tAttributes | [optional] a $tagSECURITY_ATTRIBUTES structure or a pointer to it. If 0, the handle cannot be inherited by child processes. The Descriptor member of the structure specifies a security descriptor for the new event. If $tAttributes is 0, the event gets a default security descriptor. The ACLs in the default security descriptor for an event come from the primary or impersonation token of the creator.
$bManualReset | [optional] If True, the function creates a manual-reset event object, which requires the use of the ResetEvent function to set the event state to nonsignaled. If False, the function creates an auto-reset event object and system automatically resets the event state to nonsignaled after a single waiting thread has been released.
$bInitialState | [optional] If True, the initial state of the event object is signaled; otherwise, it is nonsignaled
$sName | [optional] The name of the event object. Name comparison is case sensitive. If $sName matches the name of an existing named event object, this function requests the EVENT_ALL_ACCESS access right. In this case the $bManualReset and $bInitialState parameters are ignored because they have already been set by the creating process. If the $tAttributes parameter is not 0, it determines whether the handle can be inherited, but its security-descriptor member is ignored. If Name is blank, the event object is created without a name.

## Return Value

Success: | The handle to the event object.
Failure: | 0, @extended is set to the _WinAPI_GetLastError()

## Remarks

If the named event object existed before the function call the function returns 0 and @extended = ERROR_ALREADY_EXISTS.

## Related

$tagSECURITY_ATTRIBUTES, _WinAPI_OpenEvent

## See Also

Search CreateEvent in MSDN Library.