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
Solved

Win 3.1 won't reboot

Posted on 1998-08-27
8
179 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
Pull multiple cvs files into one access table 28 69
VB error "Type mismatch" 2 60
Windows 10 start screen issues 9 55
VB6 Compile Compatibility Issue 4 115
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

860 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