CreateEvent function kernel32

Win32Result<HANDLE> CreateEvent(
  1. Pointer<SECURITY_ATTRIBUTES>? lpEventAttributes,
  2. bool bManualReset,
  3. bool bInitialState,
  4. PCWSTR? lpName,
)

Creates or opens a named or unnamed event object.

To learn more, see learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createeventw.

Implementation

Win32Result<HANDLE> CreateEvent(
  Pointer<SECURITY_ATTRIBUTES>? lpEventAttributes,
  bool bManualReset,
  bool bInitialState,
  PCWSTR? lpName,
) {
  final result_ = CreateEventW_Wrapper(
    lpEventAttributes ?? nullptr,
    bManualReset ? TRUE : FALSE,
    bInitialState ? TRUE : FALSE,
    lpName ?? nullptr,
  );
  return Win32Result(value: HANDLE(result_.value.ptr), error: result_.error);
}