18 /***********************************************************************
21 * Clean-up everything and exit the Wine process.
22 * This is the back-end of ExitWindows(), called when all windows
23 * have agreed to be terminated.
25 void EXEC_ExitWindows(void)
27 /* Do the clean-up stuff */
36 /***********************************************************************
37 * ExitWindows16 (USER.7)
39 BOOL16
ExitWindows16( DWORD dwReturnCode
, UINT16 wReserved
)
41 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
45 /***********************************************************************
46 * ExitWindowsEx (USER32.195)
48 BOOL32
ExitWindowsEx( UINT32 flags
, DWORD reserved
)
54 /* We have to build a list of all windows first, as in EnumWindows */
56 if (!(list
= WIN_BuildWinArray( WIN_GetDesktop() ))) return FALSE
;
58 /* Send a WM_QUERYENDSESSION message to every window */
60 for (ppWnd
= list
, i
= 0; *ppWnd
; ppWnd
++, i
++)
62 /* Make sure that the window still exists */
63 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
64 if (!SendMessage16( (*ppWnd
)->hwndSelf
, WM_QUERYENDSESSION
, 0, 0 ))
69 /* Now notify all windows that got a WM_QUERYENDSESSION of the result */
71 for (ppWnd
= list
; i
> 0; i
--, ppWnd
++)
73 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
74 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ENDSESSION
, result
, 0 );
76 HeapFree( SystemHeap
, 0, list
);
78 if (result
) EXEC_ExitWindows();
83 /**********************************************************************
84 * WinHelp16 (USER.171)
86 BOOL16
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
89 return WinHelp32A( hWnd
, lpHelpFile
, wCommand
,
90 (DWORD
)PTR_SEG_TO_LIN(dwData
) );
94 /**********************************************************************
95 * WinHelp32A (USER32.578)
97 BOOL32
WinHelp32A( HWND32 hWnd
, LPCSTR lpHelpFile
, UINT32 wCommand
,
100 static WORD WM_WINHELP
=0;
105 if (wCommand
!= HELP_QUIT
) /* FIXME */
106 if(WinExec32("winhelp.exe -x",SW_SHOWNORMAL
)<=32)
108 /* FIXME: Should be directed yield, to let winhelp open the window */
111 WM_WINHELP
=RegisterWindowMessage32A("WM_WINHELP");
115 hDest
= FindWindow32A( "MS_WINHELP", NULL
);
117 if(wCommand
== HELP_QUIT
)
125 case HELP_SETCONTENTS
:
126 case HELP_CONTEXTPOPUP
:
128 case HELP_HELPONHELP
:
133 case HELP_PARTIALKEY
:
135 dsize
= strlen( (LPSTR
)dwData
)+1;
138 dsize
= ((LPMULTIKEYHELP
)dwData
)->mkSize
;
141 dsize
= ((LPHELPWININFO
)dwData
)->wStructSize
;
144 fprintf(stderr
,"Unknown help command %d\n",wCommand
);
148 nlen
= strlen(lpHelpFile
)+1;
151 size
= sizeof(WINHELP
) + nlen
+ dsize
;
152 hwh
= GlobalAlloc16(0,size
);
153 lpwh
= GlobalLock16(hwh
);
155 lpwh
->command
= wCommand
;
157 lpwh
->ofsFilename
= sizeof(WINHELP
);
158 strcpy(((char*)lpwh
) + sizeof(WINHELP
),lpHelpFile
);
161 memcpy(((char*)lpwh
)+sizeof(WINHELP
)+nlen
,(LPSTR
)dwData
,dsize
);
162 lpwh
->ofsData
= sizeof(WINHELP
)+nlen
;
166 return SendMessage16(hDest
,WM_WINHELP
,hWnd
,hwh
);
170 /**********************************************************************
171 * WinHelp32W (USER32.579)
173 BOOL32
WinHelp32W( HWND32 hWnd
, LPCWSTR helpFile
, UINT32 command
,
176 LPSTR file
= HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile
);
177 BOOL32 ret
= WinHelp32A( hWnd
, file
, command
, dwData
);
178 HeapFree( GetProcessHeap(), 0, file
);