Results 1 to 4 of 4

Thread: Exiting Windows

  1. #1

    Thread Starter
    Addicted Member cutamacious's Avatar
    Join Date
    May 2001
    Location
    INDIA >> Andhra Pradesh >> Hyderabad
    Posts
    185

    Exiting Windows

    Hi there,

    I wnat to know if i can close the Windows OS itself from my Program. I mean to say that if my program is closed/exited. the system should shutdown automatically.

    I've tried using ExitWindowsEx as below;

    Dim i As Boolean
    i = ExitWindowsEx(EWX_SHUTDOWN + EWX_FORCE, 0)

    but it only logsoff the cureent user. it is not shutting down the system. Any help is welkome.

    Thnx in adv.
    Cute Member

  2. #2
    Addicted Member
    Join Date
    May 2001
    Posts
    153

    Talking

    Hi there,

    with ExitWindowsEx() api
    try different combinations of parameters.

    Yes, I did get ur result with 1,1 in the parenthesis,

    try out exitwindowsex(1,10). It should shut down windows.

    Reply if u have got the solution.

    Cheers,
    Ven.

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Code:
    '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
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Addicted Member cutamacious's Avatar
    Join Date
    May 2001
    Location
    INDIA >> Andhra Pradesh >> Hyderabad
    Posts
    185

    Thanx

    hi VlatKo & venkrishna,

    Thnx for ur reply i've tried both of ur codes. they are working fine and r very useful to me.


    Thnx once again.
    Cute Member

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