[comp.windows.ms] Closing Down MS_DOS Executive

mikek@ziebmef.uucp (Mike King) (04/18/89)

Is there a really easy way to close Windows without the MS-DOS Executive's
"Are You Sure?" box?

There are certain circumstances in my app in which I'd like to just kill
Windows and exit to DOS.

kyler@pyr.gatech.EDU (J. Kyle Rogers) (04/22/89)

In article <1191@rlgvax.UUCP> benson@rlgvax.UUCP (Paul Benson) (Bob Thralls) writes:
> [...]
>one application can run, the multitasking is still available, use spawnl() exec
>other windows applications.
> [...]
>MS-DOS Exec is installed, I believe there is nothing wrong with spawnl().

Experience indicates that the spawn* functions do not operate correctly in
Windows.  To spawn another application from within Windows, use some magic
with Int21Function4B as discussed here recently.  The details are available
on bulletin boards with Windows info (ie OnLine/GEnie/DIAL/etc?).

---krogers
|          krogers  --  J. Kyle Rogers  --  Technology Dynamics Inc.         |
|           145 15th Street N.E., Suite 624  --  Atlanta, GA 30361           |
|uucp: ...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!kyler|
|ARPA: kyler@pyr.gatech.edu                                                  |

lak@lznh.UUCP (<10000>Lisa Krauth) (04/26/89)

I got this solution from Microsoft Tech Support:

	PostMessage((HWND)0xffff, WM_SYSCOMMAND, SC_CLOSE, (LONG)0);

Apparently the specified window handle, (0xffff), will close all windows
that are currently running.

roper@june.cs.washington.edu (Michael Roper) (04/26/89)

Lisa Krauth writes:

> I got this solution from Microsoft Tech Support:
> 
> 	PostMessage((HWND)0xffff, WM_SYSCOMMAND, SC_CLOSE, (LONG)0);
> 
> Apparently the specified window handle, (0xffff), will close all windows
> that are currently running.

Or more precisely, using 0xffff as a window handle in either
a PostMessage() or SendMessage() call will cause the message
to be sent to all top-level windows in the system -- including
the MS-DOS Executive.  Unfortunately, this does not solve the
original problem, which was how to exit windows without confronting
the confirmation message box that the Executive puts up.  Sending
the Executive the message suggested is exactly equivalent to
selecting "Close" from the Executive's control menu.

Michael Roper
hDC Computer Corporation

roper@june.cs.washington.edu (Michael Roper) (04/26/89)

Lisa Krauth writes:

> I got this solution from Microsoft Tech Support:
> 
> 	PostMessage((HWND)0xffff, WM_SYSCOMMAND, SC_CLOSE, (LONG)0);

As a postscript to my previous article on this approach, I'd
like to add that no matter what it is you are trying to do,
this is a very bad idea.  Don't do it.  If you don't care 
about the confirmation message box, just send the MS-DOS 
Executive this message exclusively.  Broadcasting an SC_CLOSE
message like this will almost certainly cause the debugging
version of windows to crash if the user decides to cancel
at confirmation time.  The reason is that this message will
close some windows you don't want closed if you're not really
leaving Windows.

You can get the window handle for the MS-DOS Executive with:

		hWnd = FindWindow( "Session", NULL );

This works even with foreign language versions of Windows.

Mike Roper
hDC Computer Corporation

nourse@jfcl.dec.com (Andy Nourse) (04/28/89)

To exit from WINDOWS straight back to DOS, without any confirmation at all,
use:
       FatalExit(0);

With a nonzero argument, WINDOWS will RIP, using the argument as a RIPcode.
With a zero argument, WINDOWS will exit normally.