Results 1 to 4 of 4

Thread: API Call to force windows to reboot?

  1. #1

    Thread Starter
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Question

    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!

  2. #2
    Lively Member
    Join Date
    Mar 1999
    Posts
    93
    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

    Regards,
    Vit

  3. #3

    Thread Starter
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126
    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!


  4. #4

    Thread Starter
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Lightbulb 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


    ben

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width