CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Forcing a ShutDown

    You can force a shutdown by doing the Following:
    First declare this API function and constant
    public Declare Function ExitWindowsEx Lib "user32" (byval uFlags as Long, byval dwReserved as Long) as Long
    public Const EWX_SHUTDOWN = 1


    Then you can call it by doing this:
    Call ExitWindowsEx(EWX_SHUTDOWN, 1) 'shut down the computer




    Please rate this posting if you like it

    F. T. W.

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Forcing a ShutDown

    I like but I am out of votes, for today (here we can rate only 5 time a day...). Let me give youa suggestion: as usually we post questions and not answers at first klevel, you should name your posts starting with:
    "Re: how to..." just to signal it is not a question, but an answer.
    Have a nice day, and thanks for all the sharing code job
    Cesare

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Forcing a ShutDown

    from api guide:
    other useful const for that api are:
    Const EWX_LOGOFF = 0
    Const EWX_SHUTDOWN = 1
    Const EWX_REBOOT = 2
    Const EWX_FORCE = 4


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Forcing a ShutDown

    Thanx! I'll remeber it next time

    F. T. W.

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

Featured