home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Exit Windows"
- ClientHeight = 4020
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7365
- Height = 4425
- Icon = WINEND.FRX:0000
- Left = 1035
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 4020
- ScaleWidth = 7365
- Top = 1140
- Width = 7485
- Declare Function ExitWindows Lib "User" (ByVal dwReserved As Long, ByVal wReturnCode As Integer) As Integer
- 'Return to DOS
- Const EW_EXITWINDOWS = &H0
- 'Reboot computer
- Const EW_REBOOTSYSTEM = &H43
- 'Exit to DOS & restart Windows
- Const EW_RESTARTWINDOWS = &H42
- 'Keep track of why Resize event
- 'is being triggered.
- Dim State%
- 'We set the EW_CURRENTEXITTYPE constant
- 'to the type of exit we want for this
- 'demonstration program.
- Const EW_CURRENTEXITTYPE = EW_EXITWINDOWS
- Sub Form_Click ()
- State% = 3 'Mark that program is in Click event
- Form1.WindowState = 1 'Minimize WinEnd
- X% = ExitWindows(EW_CURRENTEXITTYPE, 0)
- If X% = 0 Then
- MsgBox "Windows Reboot aborted by an application.", 16, "Message from WinEnd"
- 'Reset program since it was aborted
- State% = 2
- End If
- End Sub
- Sub Form_Load ()
- State% = 1
- Form1.WindowState = 1 'Minimize the form
- End Sub
- Sub Form_Resize ()
- ' The Form_Resize event procedure
- ' uses the form level variable State%
- ' to let it react to resize events
- ' based on the point at which the
- ' resize event occurs.
- 'State%'s Purpose
- ' Value
- ' 1 Used to ignore initial
- ' resize event when program
- ' launched.
- ' 2 Used to activate Form_Click
- ' event when you want to exit
- ' windows. WinEnd resets
- ' State% to 2 if the exit
- ' fails (for whatever
- ' reason).
- ' 3 Used while trying to shut
- ' down Windows to avoid
- ' displaying the WinEnd form.
- Select Case State%
- Case 1 'After FORM_LOAD
- State% = 2
- Case 2 'After activated
- Call Form_Click
- Case 3 'During FORM_CLICK
- End Select
- End Sub
-