Solved

Win 3.1 won't reboot

Posted on 1998-08-27
8
175 Views
Last Modified: 2010-04-30
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
Comment
Question by:jperrin1082798
8 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431521
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
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431522
If you want the complete code I can Email it to you

shay@hili.com
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431523
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
 

Author Comment

by:jperrin1082798
ID: 1431524
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431525
So. be it.
Thanks.
0
 
LVL 3

Expert Comment

by:dapperry
ID: 1431526
Isn't there similar functionality in a 16-bit API call?

:) D Perry
0
 
LVL 7

Accepted Solution

by:
kamall earned 20 total points
ID: 1431527
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
 

Author Comment

by:jperrin1082798
ID: 1431528
Bonk!  I'll try it with the right value...

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 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