Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Win 3.1 won't reboot

I have an application that needs to reboot win3.1 after it completes updates.  I tried this...
Declare Function ExitWindows Lib "user" (ByVal dwReturnCode As Long, ByVal wReserved As Integer) As Integer

r% = ExitWindows(1, 0)

This takes me out of windows but hangs on reboot... all I get is an underline in the upper corner of my screen.

Other programs can reboot these computers.. is there another way?
0
jperrin1082798
Asked:
jperrin1082798
1 Solution
 
a111a111a111Commented:
Hi, Here is a sample of code

============= start =============

Private Sub Yes_Click()
 If Shutdown.Value = True Then
  lresult = ExitWindowsEx(EWX_SHUTDOWN, 0&) 'shut down the computer
 ElseIf Restart.Value = True Then
  lresult = ExitWindowsEx(EWX_REBOOT, 0&) 'restart the computer
 ElseIf MSDOS.Value = True Then
  lresult = FileExists(WinPath + "\Exit to dos.pif") 'make sure the pif file exists
  If lresult = False Then 'the file could not be found
   MsgBox "Cannot find " + WinPath + "\Exit To Dos.pif" + Chr(10) + Chr(10) + "Please make sure this file is in your Windows directory", vbCritical 'display an error message
  Else                                                'otherwise
   lresult = Shell(WinPath + "\Exit To Dos.pif", 1) 'execute the pif file
  End If
 Else
  lresult = ExitWindowsEx(EWX_LOGOFF, 0&) 'close all programs and log on as a different user
 End If
End Sub

0
 
a111a111a111Commented:
If you want the complete code I can Email it to you

shay@hili.com
0
 
a111a111a111Commented:
here is a module1.bas :

========== start =======

Option Explicit

Declare Function GetVersionEx& Lib "kernel32.dll" Alias "GetVersionExA" (lpStruct As OsVersionInfo)
Declare Function AbortSystemShutdown& Lib "advapi32.dll" Alias "AbortSystemShutdownA" (ByVal lpMachineName$)
Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags&, ByVal dwReserved&)
Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Any) As Long

Type OsVersionInfo
     dwVersionInfoSize As Long
     dwMajorVersion As Long
     dwMinorVersion As Long
     dwBuildNumber As Long
     dwPlatform As Long
     szCSDVersion As String * 128
End Type

Private OsVer As OsVersionInfo
Global Const VER_PLATFORM_WIN32_WINDOWS = 1
Global Const VER_PLATFORM_WIN32_NT = 2
Global Const EWX_FORCE = 4 'constants needed for exiting Windows
Global Const EWX_LOGOFF = 0
Global Const EWX_REBOOT = 2
Global Const EWX_SHUTDOWN = 1

Global Const HELP_QUIT = 2
Global Const HELP_INDEX = 3
Global Const HELP_HELPONHELP = 4
Global Const HELP_PARTIALKEY = &H105



use all  what you need and "'REM" or delete the others.


Again if any one link the complete project please welcome to email shay@hili.com

shay@hili.com
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jperrin1082798Author Commented:
Thats Great Code, And I'll keep it around... but is uses the kernel32 and this app is written for vb4 and win3.1.
0
 
a111a111a111Commented:
So. be it.
Thanks.
0
 
dapperryCommented:
Isn't there similar functionality in a 16-bit API call?

:) D Perry
0
 
kamallCommented:
You are giving the wrong value for the argument. Here it is:

Global Const EW_REBOOTSYSTEM = &H43

So, you should write:

r% = ExitWindows(EW_REBOOTSYSTEM, 0)

Regards.
P.S. 10 points are really very little for any question.
0
 
jperrin1082798Author Commented:
Bonk!  I'll try it with the right value...

PS 10 points were all I had left...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now