How to Reboot the System from Within FoxPro

Last reviewed: April 30, 1996
Article ID: Q109607
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b

SUMMARY

Occasionally it may be necessary to change the AUTOEXEC.BAT or CONFIG.SYS file in order to help a FoxPro-generated .EXE file run better under Windows. By using the Windows API function ExitWindows(), you can give the user a choice of rebooting the system now or later.

See below for more details and a code sample.

MORE INFORMATION

By using FOXTOOLS.FLL and the Windows API function ExitWindows(), you can reboot the entire system. The following code illustrates this concept.

NOTE: While it is possible to reboot the system 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
   bootup=REGFN("ExitWindows","II","I")
   title="Program Message"
   msg="Changes have been made to your CONFIG.SYS. " + ;
      "Choose 'Yes' to reboot your system so changes can " + ;
      "take effect. Choose 'No' to continue without rebooting."
   choice=MSGBOX(msg,title,20)
   IF choice=6 && button 'Yes' was chosen
      =CALLFN(bootup,67,0)
   ELSE
      WAIT WINDOW "You have chosen to continue" TIMEOUT 2
   ENDIF

   *** End Code ***

The ExitWindows() function requires two numeric values to be passed to it and returns a single integer. The significance of the first integer (67) is that it is the decimal equivalent of 0x43 hexadecimal or EW_REBOOTSYSTEM, 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 terminate Windows. If all applications "agree" to be terminated, the WM_ENDSESSION message will be sent to all applications before Windows is terminated.

REFERENCES

Visual C++ Help file

Microsoft Windows Software Development Kit, "Programmer's Reference, Volume 2: Functions," page 290

FOXTOOLS.WRI located in the C:\FOXPROW\GOODIES\FOXTOOLS subdirectory


Additional reference words: VFoxWin 3.00 FoxWin 2.50 2.50a 2.50b quit
restart SDK API
FOXTOOLS.FLL
KBCategory: kbinterop kbenv kbtool kbprg kbcode
KBSubcategory: FxprgFoxtools


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.