Function Reference


Creates or opens a named or unnamed event object

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


$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()


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



See Also

Search CreateEvent in MSDN Library.


#include <WinAPIHObj.au3>
#include <WinAPIProc.au3>

Global $g_tEvents = DllStructCreate("handle Event[3];")
$g_tEvents.Event(1) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(2) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(3) = _WinAPI_CreateEvent(0, True, False)

HotKeySet("{ESC}", "_Exit")
AdlibRegister("_FireEvent_1", 500)
AdlibRegister("_FireEvent_2", 800)

Local $iEvent
While 1
        $iEvent = _WinAPI_WaitForMultipleObjects(3, $g_tEvents, False, 100)
        Switch $iEvent
                Case 0
                        ConsoleWrite("+ First Event" & @CRLF)
                Case 1
                        ConsoleWrite("> Second Event" & @CRLF)
                Case 2
                        ConsoleWrite("! Exit Event" & @CRLF)
                Case -1 ;Error

Func _Exit()
EndFunc   ;==>_Exit

Func _FireEvent_1()
EndFunc   ;==>_FireEvent_1

Func _FireEvent_2()
EndFunc   ;==>_FireEvent_2