Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Win 3.1 won't reboot

Posted on 1998-08-27
8
Medium Priority
?
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses

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