Commit 20afe30d authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

- If given the EWX_FORCE flag, ExitWindowsEx() should not send the

WM_{QUERY}ENDSESSION messages. - Add support for EWX_FORCEIFHUNG. - ExitWindowsEx() should return true if it succeeds, even if the user cancels the shutdown. - Don't crash if there are no windows.
parent d06a464c
......@@ -409,31 +409,37 @@ static BOOL USER_StartRebootProcess(void)
BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reserved )
{
int i;
BOOL result;
BOOL result = FALSE;
HWND *list, *phwnd;
/* We have to build a list of all windows first, as in EnumWindows */
TRACE("(%x,%lx)\n", flags, reserved);
if (!(list = WIN_ListChildren( GetDesktopWindow() ))) return FALSE;
/* Send a WM_QUERYENDSESSION message to every window */
for (i = 0; list[i]; i++)
{
/* Make sure that the window still exists */
if (!IsWindow( list[i] )) continue;
if (!SendMessageW( list[i], WM_QUERYENDSESSION, 0, 0 )) break;
}
result = !list[i];
/* Now notify all windows that got a WM_QUERYENDSESSION of the result */
for (phwnd = list; i > 0; i--, phwnd++)
list = WIN_ListChildren( GetDesktopWindow() );
if (list)
{
if (!IsWindow( *phwnd )) continue;
SendMessageW( *phwnd, WM_ENDSESSION, result, 0 );
/* Send a WM_QUERYENDSESSION message to every window */
for (i = 0; list[i]; i++)
{
/* Make sure that the window still exists */
if (!IsWindow( list[i] )) continue;
if (!SendMessageW( list[i], WM_QUERYENDSESSION, 0, 0 )) break;
}
result = !list[i];
/* Now notify all windows that got a WM_QUERYENDSESSION of the result */
for (phwnd = list; i > 0; i--, phwnd++)
{
if (!IsWindow( *phwnd )) continue;
SendMessageW( *phwnd, WM_ENDSESSION, result, 0 );
}
HeapFree( GetProcessHeap(), 0, list );
if ( !(result || (flags & EWX_FORCE) ))
return FALSE;
}
HeapFree( GetProcessHeap(), 0, list );
/* USER_DoShutdown will kill all processes except the current process */
USER_DoShutdown();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment