USER32: ExitWindowsEx fixes
Mike McCormack
mike at codeweavers.com
Mon Jan 3 02:43:51 CST 2005
ChangeLog:
<fgouget at codeweavers.com>
* 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's no windows
<julliard at codeweavers.com>
* Use ExitProcess to terminate the process in ExitWindowsEx so that it
gets a chance to clean things up
-------------- next part --------------
Index: windows/user.c
===================================================================
RCS file: /home/wine/wine/windows/user.c,v
retrieving revision 1.105
diff -u -r1.105 user.c
--- windows/user.c 8 Dec 2004 18:06:14 -0000 1.105
+++ windows/user.c 3 Jan 2005 08:44:07 -0000
@@ -409,31 +409,37 @@
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++)
+ list = WIN_ListChildren( GetDesktopWindow() );
+ if (list)
{
- /* Make sure that the window still exists */
- if (!IsWindow( list[i] )) continue;
- if (!SendMessageW( list[i], WM_QUERYENDSESSION, 0, 0 )) break;
- }
- result = !list[i];
+ /* Send a WM_QUERYENDSESSION message to every window */
- /* Now notify all windows that got a WM_QUERYENDSESSION of the result */
+ 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 );
- for (phwnd = list; i > 0; i--, phwnd++)
- {
- if (!IsWindow( *phwnd )) continue;
- SendMessageW( *phwnd, WM_ENDSESSION, result, 0 );
+ if ( !(result || (flags & EWX_FORCE) ))
+ return FALSE;
}
- HeapFree( GetProcessHeap(), 0, list );
/* USER_DoShutdown will kill all processes except the current process */
USER_DoShutdown();
@@ -441,7 +447,7 @@
if (flags & EWX_REBOOT)
USER_StartRebootProcess();
- if (result) ExitKernel16();
+ if (result) ExitProcess(0);
return TRUE;
}
More information about the wine-patches
mailing list