Solved

Windows95 Shutdown processing

Posted on 1997-09-13
7
257 Views
Last Modified: 2013-12-29
In Windows 3.1 Winstart.bat is used to run processes when windows is started but before it is loaded.  How do you do this sort of thing when you click on the shutdown button.  Alternatively, how can you shutdown without start-> shtudown or Ctrl-Alt-Del -> shutdown.  Is there a command or system call to do this?
0
Comment
Question by:garna
  • 4
  • 2
7 Comments
 
LVL 9

Expert Comment

by:magigraf
ID: 1696529
Actually the easiest way to do it is to head to http://www.windows.com.  There you will find a lot of utilities and shareware, among them is a little program that runs a stay in your systray and when you click on it it will shut down windows.

Hope this helped
Regards
0
 
LVL 9

Expert Comment

by:magigraf
ID: 1696530
Here... I found the page for you:
http://www.windows95.com/apps/startmenu.html
one of them is ClickDown
0
 
LVL 1

Author Comment

by:garna
ID: 1696531
I need that sort of functionality to be attached to the Start->shutdown or Ctrl-Alt-Del->Shutdown routine.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 9

Expert Comment

by:magigraf
ID: 1696532
You mean you want to write a little program and propose it to Bill Gate so he could include it in his Windows 98 release??
0
 
LVL 1

Author Comment

by:garna
ID: 1696533
So it can't be done then.  How then do Applications that need to restart windows95, actually cause the restart to happen.  There must be a way.
0
 
LVL 9

Expert Comment

by:magigraf
ID: 1696534
By invoking API. And since I'm not a programmer to know how they do it, I guess my answers will stop here.
I know what you want! but.... I'll keep looking, in the meantime maybe someone else will post an answer!
0
 
LVL 25

Accepted Solution

by:
dew_associates earned 100 total points
ID: 1696535
Garna: Windows 3.xx is a 16 bit application heavily intergrated with DOS conventions, whereas Windows 95 is a 32-bit application relying upon "api" interface and "ddl's". In addition, in windows 3.xx, as each application closed it performed it's own cleanup including dumping temp files etc, and moreover windows 3.xx did not use and dynamic programming hooks as does windows 95. On the other hand, windows 95 does not do all of this cleanup until after it has begun the shutdown process, whereupon it notifies every program running that they should close and clean up and then waits for an answer from each one.
To dynamically reboot windows 95 would cause the files in c:\windows\temp to be abandoned. You can develop an api interface to accomplish your task and do the cleanup, as
Microsoft has made available the windows 95 sdk to enable people to do just that. It's available as a free download.
=====================
Here's some info and an example:
=====================
The MSSetup Toolkit does not provide a way for the user to arbitrarily and cleanly reboot the computer without having the RestartListEmpty function return 0 (zero). The NSETUP sample provides a work around for this situation by providing a mechanism for the user to communicate with the
MSSetup dynamic-link libraries (DLLs) to cleanly reboot the computer without having a system file on the RestartList.
 
Download NSETUP.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:
 
 - Microsoft Download Service (MSDL)
      Dial (206) 936-6735 to connect to MSDL
      Download NSETUP.EXE
 
 - Internet (anonymous FTP)
      ftp ftp.microsoft.com
      Change to the \SOFTLIB\MSLFILES directory
      Get NSETUP.EXE
 
The MSSetup Toolkit occupies a relatively small footprint in memory while providing much of the functionality needed to author a full-featured installation program. MSSetup accomplishes this low memory requirement by having a small fixed code stub program (SETUP.EXE) copy over the larger
DLLs to a temporary directory on the user's hard disk. When the script exits, this small fixed code stub cleans up after the installation script by deleting the DLLs from the user's temporary directory.
 
Another feature built into the MSSetup Toolkit is the ability to let the user install system level DLLs while they are loaded in memory at the time of installation. MSSetup accomplishes this by maintaining a list of files that need to be installed while Windows is rebooted. The MSSetup script author accomplishes this by calling the MSSetup functions RestartListEmpty and ExitExecRestart.
 
There is no functionality built into the MSSetup Toolkit, however, to allow the user to arbitrarily reboot Windows. A cursory examination of this situation might yield a workaround involving the call to Windows-based application programming interface (API) ExitWindows or ExitWindowsExec via the MSSetup script. However, there is a problem with this approach. Upon rebooting the system, the user will find all the MSSetup DLLs still present in the temporary directory. Because Windows exits more or less immediately upon the call to ExitWindows or ExitWindowsExec, the Setup stub program (SETUP.EXE) never has a chance to perform its cleanup (see paragraph above). To expect the installation script to provide this type of functionality further complicates the situation.
 
Another approach to the situation is to let MSSetup handle the cleanup as it would normally. NSETUP launches SETUP.EXE and waits for it to clean up and terminate. In this manner, NSETUP relies on SETUP.EXE's behavior to delete the files in the temporary directory. The sample also demonstrates a
technique for communicating between the MSSetup script and the NSETUP program via the Windows function RegisterWindowMessage.
 
In many ways, the NSETUP sample is similar to SETUP.EXE; it is a fixed code stub program, which WinExecs SETUP.EXE and then waits in the background for the program to finish. When SETUP.EXE finishes, NSETUP consults a reboot flag set via a message sent from the MSSetup script. If the user has chosen
to reboot, NSETUP makes a call to ExitWindows.
========================
 
The Microsoft Visual Basic for Windows SendKeys function cannot be used to
close the Microsoft Windows Program Manager in order to terminate Microsoft
Windows. To correctly close Program Manager, you must invoke the
ExitWindows API function, as shown below.
 
Many software setup or installation programs are designed to exit Windows,
and then restart Windows when the setup or installation is complete. You
can make a Visual Basic program automatically exit Windows and then restart
Windows by passing the EW_RESTARTWINDOWS value to the ExitWindows API
function. The value for the EW_RESTARTWINDOWS constant is &H42.
 
MORE INFORMATION
================
You may want to terminate the current Windows session by closing the Program Manager from within a Visual Basic application. You may think that you can activate the Program Manager control menu and send the appropriate key sequences using the Visual Basic SendKeys function. However, this
method does not work because after the Close menu item is chosen, a system modal dialog box is opened that prompts you to save changes to Program Manager. A system modal dialog box locks out ALL other programs until it is satisfied. Therefore, the keystroke you send by using the SendKeys function
never arrives in the dialog box.
 
To correctly close Program Manager, you must use the ExitWindows API function. You can declare this API function in a code module name Module1.
 
Step-by-Step Example
--------------------
1. Start a new project in Visual Basic.
2. Draw a command button on the form.
3. Add the following as a single line to Module1:

   ' Use for Windows 3.11 or Windows for Workgroups 3.11 applications:
    Declare Function ExitWindows Lib "user" (ByVal wReturnCode as Long, _
    ByVal dwReserved as Integer) as Integer
 
   ' Use for Windows 95 or Windows NT applications:
      Declare Function ExitWindows Lib "user32" alias "ExitWindowsEx" _
         (ByVal wReturnCode as Long, ByVal dwReserved as Long) as Long
 
4. Add the following line of code to the command button's Click procedure:
 
   ' Use for Windows 3.11 or Windows for Workgroups 3.11 applications:
      RetVal% = ExitWindows(0,0)
 
   ' Use for Windows 95 or Windows NT Applications:
      RetVal& = ExitWindows(0&, 0&)
 
5. Run the program.
6. Click the command button.
 
The ExitWindows API call initiates the standard Windows shutdown procedure. If all applications agree to terminate, the windows session is terminated and control returns to MS-DOS. If the ExitWindows API call fails due to an open MS-DOS session or for some other reason, FALSE is returned. You should
check for this return value and handle it appropriately.
 
Steps to Reproduce Behavior
---------------------------
 
1. Start a new Project in Visual Basic.
2. Draw a command button on the form.
3. In the command button Click event procedure, add this code:

   AppActivate("Program Manager")
   SendKeys "%{ }{DOWN 5}{ENTER 2}", 0  'ALT, SPACE, DOWN 5, ENTER 2
 
4. Run the program.
 
The Program Manager does not close. If you choose the OK button with the mouse, a message is displayed stating, "Can't quit at this time." If you choose the Cancel button, a message is displayed stating, "Cannot start more than one copy of the specified program." These messages are misleading, but are the result of attempting an unsupported action.
 
Additional reference words: 4.00 vb4win vb416 restart start exit windows
=========================
EXAMPLE
=========================
You can restart Windows from inside a FoxPro for Windows application by using the Windows API function ExitWindows(). With this function, you can restart Windows without rebooting the entire system, as explained below.
 
MORE INFORMATION
================
By using FOXTOOLS.FLL and the Windows API function ExitWindows(), you can restart Windows. The following code illustrates this concept.
 
NOTE: While it is possible to restart Windows from within a FoxPro for Windows program by making use of the Windows API function ExitWindows(), FoxPro may not do a complete cleanup and may leave *.TMP files in your SET
TEMP= subdirectory.
 
   *** Begin Code ***
   * WARNING: Make sure all work is saved before running code
 
  SET LIBRARY TO SYS(2004)+"FOXTOOLS.FLL" ADDITIVE
   do_over=REGFN("ExitWindows","II","I")
   title="Program Message"
   msg="Would you like to restart Windows now?"
   choice=MSGBOX(msg,title,36)
   IF choice=6    && button 'Yes' was chosen
      =CALLFN(do_over,66,0)
   ELSE
      WAIT WINDOW "You have chosen not to restart Windows" TIMEOUT 2
   ENDIF
   *** End Code ***
 
The ExitWindows() function requires two numeric values to be passed in and returns a single integer. The significance of the first integer (66) is that it is the decimal equivalent of 0x42 hexadecimal or EW_RESTARTWINDOWS, which is a low-order word in the C++ language. The second integer is
reserved and is always zero. When the ExitWindows() function is called, it sends a message to all active applications that a request has been made to restart Windows. If all applications "agree" to be terminated, the WM_ENDSESSION message will be sent to all applications before Windows is restarted.
 
Hope this helps you!
0

Featured Post

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Join & Write a Comment

Suggested Solutions

Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now