I am currently writing and testing an installation program which will soon be distributed. During the this process, I edit the SYSTEM.INI file. Most Windows software willallow you to “Reboot” windows to allow the new configuration to take effect. Could you please tell me the technique usedin VB to make this happen? Also, could you please tellme how to exit Windows and re-boot the machine in case I make changes in the AUTOEXEC.BAT and CONFIG.SYS file?
The ExitWindows API function performs this function. The documentation for it is in the Windows 3.1 SDK help file. The one thing to note on this is that it does not override normal behavior of applications that ask to save before exiting. The ExitWindows API function, therefore, could end up not executing.
Here is an example of how to use the ExitWindows API under VB4 (32-bit). For VB3, refer to the Windows 3.1 SDK help file or the VB API Text Viewer.
1. Start a new project in Visual Basic. Form1 is created by default.2. Add the following code to the General Declarations portion of Form1: Const EWX_LogOff As Long = 0 Private Declare Function ExitWindows Lib “User32” _ Alias “ExitWindowsEx” _ (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long3. Add the following code to the Form_Click event: ExitWindows EWX_LogOff, &HFFFFFFFF4. Save the project for future use, if desired.5. Choose Make EXE File… from the File menu to compile the program.6. Close all running instances of Visual Basic and run the compiled EXE.7. Click the Form. Windows will close all running applications and log the user off from the current Windows session.