Exiting and Restarting Windows

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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a