4 * Copyright 1998 Alexandre Julliard
15 /***********************************************************************
16 * CreateEvent32A (KERNEL32.156)
18 HANDLE WINAPI
CreateEventA( SECURITY_ATTRIBUTES
*sa
, BOOL manual_reset
,
19 BOOL initial_state
, LPCSTR name
)
21 struct create_event_request
*req
= get_req_buffer();
23 req
->manual_reset
= manual_reset
;
24 req
->initial_state
= initial_state
;
25 req
->inherit
= (sa
&& (sa
->nLength
>=sizeof(*sa
)) && sa
->bInheritHandle
);
26 lstrcpynA( req
->name
, name
? name
: "", server_remaining(req
->name
) );
28 server_call( REQ_CREATE_EVENT
);
29 if (req
->handle
== -1) return 0;
34 /***********************************************************************
35 * CreateEvent32W (KERNEL32.157)
37 HANDLE WINAPI
CreateEventW( SECURITY_ATTRIBUTES
*sa
, BOOL manual_reset
,
38 BOOL initial_state
, LPCWSTR name
)
40 LPSTR nameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, name
);
41 HANDLE ret
= CreateEventA( sa
, manual_reset
, initial_state
, nameA
);
42 if (nameA
) HeapFree( GetProcessHeap(), 0, nameA
);
46 /***********************************************************************
47 * WIN16_CreateEvent (KERNEL.457)
49 HANDLE WINAPI
WIN16_CreateEvent( BOOL manual_reset
, BOOL initial_state
)
51 return CreateEventA( NULL
, manual_reset
, initial_state
, NULL
);
55 /***********************************************************************
56 * OpenEvent32A (KERNEL32.536)
58 HANDLE WINAPI
OpenEventA( DWORD access
, BOOL inherit
, LPCSTR name
)
60 struct open_event_request
*req
= get_req_buffer();
63 req
->inherit
= inherit
;
64 lstrcpynA( req
->name
, name
? name
: "", server_remaining(req
->name
) );
65 server_call( REQ_OPEN_EVENT
);
66 if (req
->handle
== -1) return 0; /* must return 0 on failure, not -1 */
71 /***********************************************************************
72 * OpenEvent32W (KERNEL32.537)
74 HANDLE WINAPI
OpenEventW( DWORD access
, BOOL inherit
, LPCWSTR name
)
76 LPSTR nameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, name
);
77 HANDLE ret
= OpenEventA( access
, inherit
, nameA
);
78 if (nameA
) HeapFree( GetProcessHeap(), 0, nameA
);
83 /***********************************************************************
86 * Execute an event operation (set,reset,pulse).
88 static BOOL
EVENT_Operation( HANDLE handle
, enum event_op op
)
90 struct event_op_request
*req
= get_req_buffer();
93 return !server_call( REQ_EVENT_OP
);
97 /***********************************************************************
98 * PulseEvent (KERNEL32.557)
100 BOOL WINAPI
PulseEvent( HANDLE handle
)
102 return EVENT_Operation( handle
, PULSE_EVENT
);
106 /***********************************************************************
107 * SetEvent (KERNEL32.644)
109 BOOL WINAPI
SetEvent( HANDLE handle
)
111 return EVENT_Operation( handle
, SET_EVENT
);
115 /***********************************************************************
116 * ResetEvent (KERNEL32.586)
118 BOOL WINAPI
ResetEvent( HANDLE handle
)
120 return EVENT_Operation( handle
, RESET_EVENT
);
124 /***********************************************************************
125 * NOTE: The Win95 VWin32_Event routines given below are really low-level
126 * routines implemented directly by VWin32. The user-mode libraries
127 * implement Win32 synchronisation routines on top of these low-level
128 * primitives. We do it the other way around here :-)
131 /***********************************************************************
132 * VWin32_EventCreate (KERNEL.442)
134 HANDLE WINAPI
VWin32_EventCreate(VOID
)
136 HANDLE hEvent
= CreateEventA( NULL
, FALSE
, 0, NULL
);
137 return ConvertToGlobalHandle( hEvent
);
140 /***********************************************************************
141 * VWin32_EventDestroy (KERNEL.443)
143 VOID WINAPI
VWin32_EventDestroy(HANDLE event
)
145 CloseHandle( event
);
148 /***********************************************************************
149 * VWin32_EventWait (KERNEL.450)
151 VOID WINAPI
VWin32_EventWait(HANDLE event
)
153 SYSLEVEL_ReleaseWin16Lock();
154 WaitForSingleObject( event
, INFINITE
);
155 SYSLEVEL_RestoreWin16Lock();
158 /***********************************************************************
159 * VWin32_EventSet (KERNEL.451)
161 VOID WINAPI
VWin32_EventSet(HANDLE event
)