Solved

Win 3.1 won't reboot

Posted on 1998-08-27
8
181 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
Independent Software Vendors: 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!

 

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
 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
Adding to a VBA? 6 82
Create Files based on Cell Values in a Range in Excel 12 43
Powerpoint 2013: Change cell reference in excel link 3 119
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

679 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