-
Hi everyone,
Can anyone point me to any posts concerning rebooting the system via an API call? I know this should be in the API forum, but- hey no one reads that anyway.
I thought it was something like:
ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
I've seen an example from John that uses this calls, but it seems not to have any effect- will it work on NT?
Sorry to ask such a stupid question (after a 3month absence from vb-world, I didn't even recognise the site!!)
John/James - THANKS! The new organisation and features are superb!
-
Here's the code (hope it's it)
'In general section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load() msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
If msg = vbCancel Then End
'reboot the computer
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub
-
Yeah- that's the code I've seen.
It doesn't seem to have any effect :(
I've tried it on NT4/2000 - maybe that's the cause- if so does anyone know what the NT equivalent of this call would be.
Ta!
-
And the answer is......
I've found the answer:
ExitWindowsEx cannot shutdown a Windows NT or 2000 system.
In order to do so, the SE_SHUTDOWN_NAME priviledge must be set.
More info: http://support.microsoft.com/support.../Q176/6/95.ASP
:D
ben