-----------------------------------------------------------
                        RESTART
                A Windows Restart Utility
                (c) 1993, Jeffrey M. Perkel
                   All rights reserved
-----------------------------------------------------------

//////////////////////////////////////////////////
Legal Stuff
//////////////////////////////////////////////////

This program is distributed as freeware.  You are free to
distribute it so long as this README.TXT file remains with
it.  You are also free to modify the code, but please e-mail
me any suggestions or fixes or even (ack!) bugs, at

                	perkel_j@pobox.upenn.edu

Windows is a registered trademark and is owned by Microsoft
Corporation.  All other tradenames are owned by their 
respective companies.  

THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                                                       
//////////////////////////////////////////////////
File List and Installation
//////////////////////////////////////////////////

Required:

	RESTART.EXE		- Required executable
	CTL3D.DLL		- Required DLL for 3d effects.

Optional:

	RESTART.C		- C source code
	RESTART.H		- Source code header file
	RESTART1.RC		- Resource templates for RESTART
	RESOURCE.H		- APPSTUDIO created header file
	RESTART.DEF		- Module definition file
	RESTART.MAK		- Visual C++ 1.0 make file	
	RESTART.ICO		- RESTART icon
		
To install RESTART, simply copy the file RESTART.EXE into the
directory of your choice (e.g., your utility directory), and copy
CTL3D.DLL into the \SYSTEM subdirectory of Windows (e.g., 
C:\WINDOWS\SYSTEM).  This file is REQUIRED to run RESTART.  Do not
delete it!!!

You may choose to create a Program Manager icon for RESTART.  Follow
these steps to do so:

	1.  Select File | New from the Program Manager menu.
	2.  Select Program Item.
	3.  Enter the desired icon name, and its path.  For example, to
		have RESTART restart without confirmation, enter:
			C:\UTIL\RESTART /R /C
			
		Be sure to change "UTIL" to the correct pathname.
	4.  Select OK.
			
//////////////////////////////////////////////////
Why RESTART?
//////////////////////////////////////////////////

It is sometimes necessary to restart Windows in order to have 
changes in the system files(i.e., WIN.INI, SYSTEM.INI) take effect.
RESTART allows you to do this without having to exit, and then
restart.  In addition, RESTART allows you to reboot your system
from Windows 3.1.  

RESTART is also a useful tool for recovering system resources
which may have been lost as a result of applications exiting without
fully releasing allocated memory.  The gain of system resources in
such situations may be quite substantial (I've used RESTART to
recover over 20% of my FSR!).

//////////////////////////////////////////////////
Program Usage and Syntax
//////////////////////////////////////////////////

Syntax:  RESTART [switches]
        Switches:  R - Restart Windows
                   E - Exit Windows
                   S - Reboot System
                   C - Turn OFF confirmation (default is ON)
                   
NOTE:  Invoking RESTART using the command line switches automatically 
turns confirmation on, unless you specify the /c parameter.

RESTART, as its name implies, is a small utility that allows 
the user to restart Windows, exit Windows, or reboot the
system (Windows 3.1 only).  To use RESTART, simply 
execute RESTART, select the desired action, and press Go!. 
You can quit the program by selecting Cancel, or Close in the
system menu. The dialog box contains a "Confirmation On" 
checkbox. Uncheck this box to avoid the confirmation dialog
box.  It also contains a "Save On Exit" checkbox.  Checking this
box causes the Confirmation state to be saved in WIN.INI, as well
as the last RESTART option chosen.  For example, if you choose to
"Restart", with "Confirmation On", and save settings, the following
lines will be added to WIN.INI:

        [Restart]
        ConfirmationOn=1
        LastOption=1  <= (0=Exit, 1=Restart, 2=Reboot)

It is important that these options not be modified except by RESTART;
manual modification of these parameters may result in unpredictable
program execution.

You can set RESTART to run automatically by creating an icon in
Program Manager.  Simply create a new program icon, and then
enter the command line switch that you desire.  For example to
have RESTART restart Windows without invoking the main dialog box,
simply enter:  C:\UTIL\RESTART /R                        

To have RESTART exit Windows without invoking the main dialog OR the
confirmation dialog, enter:  C:\UTIL\RESTART /E /C

Note that if you run RESTART with other applications open whose
data is unsaved, these applications will prompt you to save before
exit.  Pressing "Cancel" will cancel the restart operation, and
will generate a "One or more applications refused to terminate!"
box.

//////////////////////////////////////////////////
Technical Details
//////////////////////////////////////////////////

RESTART is written in C and is compiled using Microsoft Visual
C++ 1.0 and the Windows 3.1 SDK.  The code is written based upon
a similar design by Mike Sax, as originally written in Dr. 
Dobbs Journal (UNLOAD.EXE).  

When RESTART is invoked, it calls the function ParseCmdLine(),
which determines if any command line switches have been used.
If they have, the variable bCmdLineParam is set to TRUE, and,
depending upon the switch, the variable Action is set either to
EW_RESTARTWINDOWS, EW_REBOOTSYSTEM, or NULL (see below).  
If an incorrect switch is used, the program notifies the user 
and invokes the main dialog box.

If no command line parameter has been used, the main dialog box
is created normally, and the appropriate boxes are checked based
upon the settings in WIN.INI.  RESTART then waits for user input.
The program works by checking the status of the radio buttons
when Go! is pressed:

        int Action;
        BOOL bAnswer, bSuccess;
        
        Action = (IsDlgButtonChecked(hDlg, IDD_RESTART)) ?
                EW_RESTARTWINDOWS : (IsDlgButtonChecked (hDlg, 
                IDD_EXIT)) ? NULL : (IsDlgButtonChecked (hDlg,
                IDD_REBOOT) ? EW_REBOOTSYSTEM : NOCHECK;
        if (Action == NOCHECK)
                {
                MessageBeep(0);
                break;
                }
        bAnswer = AreYouSure (hDlg, Action);
        if (!bAnswer) break;
        bSuccess = MakeItSo (Action);
        if (!bSuccess) {
                ErrorHandler (hDlg, ERR_APPREFUSETERMINATE);
                }
        break;
        
The MakeItSo() function simply passes the results of the
IsDlgButtonChecked() call to ExitWindows():

        ExitWindows (Action, 0);

ExitWindows() can actually accept 3 different options:
EW_RESTARTWINDOWS, EW_REBOOTSYSTEM, or NULL.  EW_REBOOTSYSTEM
will cause Windows to terminate and the system to restart.
As this flag is new to Windows 3.1, part of the startup code for
RESTART determines the current version of Windows, and, if it is
less than 3.1, disables this option.

/////////////////////////////////////////////////////
Version History
/////////////////////////////////////////////////////

10 August 1993  Ver. 1.0        First version.
15 August 1993  Ver. 1.0.1      Fixed a bug that caused RESTART to
        exit Windows if neither Dialog Button was checked.
18 August 1993  Ver. 1.1        Fixed a bug that prevented RESTART from 
        exiting Windows.  Added confirmation dialog boxes.
20 August 1993  Ver. 1.2        Added feature to allow user to turn off
        Confirmation dialog box.  Added an About... box.  (Thanks to
        Willem Bison wbison@xs4all.hacktic.nl for help with this!)
1 Sept. 1993    Ver. 1.3        Added command line switches and parsing.
7 Sept. 1993    Ver. 1.4        Modified ParseCmdLine() algorithm and
        optimized code slightly.        
14 Sept. 1993   Ver. 1.4.1      Fixed bug that caused improper handling
        of applications refusing to terminate if RESTART invoked using
        command line switches.
15 Sept. 1993   Ver. 1.4.2      Fixed bug that caused RESTART to prompt
        for Exit if invoked with a command line switch using any char
        other than '/' or '-'.
6 Nov. 1993     Ver. 1.5        Added logic for EW_REBOOTSYSTEM,
        including a new command line argument.
11 Nov. 1993    Ver. 1.5.1      Added logic to save confirmation setting
        and last choice in WIN.INI.  Also, added fix to prevent multiple
        instances.         
10 May 1994		Ver. 1.6.0		Added the /c parameter.
