|
-
May 22nd, 2000, 12:50 AM
#1
Thread Starter
Lively Member
Can someone take a look at this and give me an idea of what I might be doing incorrectly. I am trying to reboot windows from within a VB 6.0 app on a Windows NT 4.0 machine. When running it, I receive no error messages, but the machine does not seem to respond at all to the request.
===========================================================
Public Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Public Const EWX_REBOOT = 2
-----------------------------------------------------------
ExitWindowsEx EWX_REBOOT, 0
===========================================================
Thanks.
Jay D Zimmerman
-
May 22nd, 2000, 07:05 PM
#2
Hyperactive Member
-
May 22nd, 2000, 08:35 PM
#3
Lively Member
Windows NT does not allow ExitWindows & ExitWindowsEx
The above tip won't work - because you're running Windows NT. Windows NT, as a security measure, demands that programs explicitly request access to shut down the machine - if this is not done, the kernel silently ignores the shutdown request. I'm not going to go into the necessary AdjustTokenPrivileges calls; there are dozens of examples in the forum, just use the search feature.
- Steve
Real programmers use COPY CON PROGRAM.EXE
-
May 22nd, 2000, 08:59 PM
#4
Thread Starter
Lively Member
I took a look at the web site that you posted, but it did not work. However, via the Microsoft Knowledge Base, I did locate an article that describes the shutting down of Windows in the NT environment. I thought I would post the URL in case anyone else (a)was having the same problems or (b)wanted to keep in on file for future use. Thanks for all of your help.
http://support.microsoft.com/support...-US&SD=gn&FR=0
Jay D Zimmerman
-
May 23rd, 2000, 02:55 PM
#5
PowerPoster
ExitWindowsEx API function
Just Paste this into your code & it should work.
Code:
Option Explicit
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
Dim ret&
'Log Off the current user.
ret& = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0)
'Shutdown the current windows
ret& = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
'Reboot the windows
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
'Don't what this does? May be you can find it out...
ret& = ExitWindowsEx(EWX_FORCE Or EWX_FORCE, 0)
End Sub

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|