|
Not sure about the java aspects, but the following normally happens after a windows shutdown of logoff is initiated.
1) All windows applications will receive a WM_QUERYENDSESSION message asking for permission to shutdown. An application can indicate, by setting an appropriate flag, that it does want to allow the shutdown/logoff.
2) All windows applications will receive a WM_ENDSESSION message, with a value indicating whether the shutdown is proceeding or not. If shutdown or logoff is occurring, that flag is TRUE.
3) There are a set of similar signals sent to each console process (eg the DOS prompt), to make them shut down as well. I've never developed a console application that needed to respond to a windows shutdown event, so can't give more details.
4) If shutdown is happening, each program is terminated (the sequence of events such as WM_CLOSE for windows applications). This allows the applications to clean up as they terminate (including doing things like prompting a user to save files, which is why a shutdown will not occur while a program waits for user input).
The above is what happens in response to a user manually initiates a shutdown or logs off. It can also be initiated programatically with a call to the win32 API functions ExitWindows() or ExitWindowsEx(). ExitWindowsEx() accepts a flag that allows bypassing of the protocol of asking programs for permission to shutdown in emergency situations (it basically shuts down applications with prejudice, and does not allow data to be saved) --- that can't be done manually. Such a technique is one that should be used with extreme caution, as it can make your program unpopular with users.
|