Shutdown from c++
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Shutdown from c++

  1. #1
    Member
    Join Date
    Dec 2001
    Posts
    94

    Shutdown from c++

    Anybody knows how to shut-down a system from c++ program.
    I can restart but don't know how to shutdown it.

    Some other info if that helps (hey, who knows...):
    i use borland 3.0 dos compiler and OS=win98

  2. #2
    Senior Member
    Join Date
    Oct 2001
    Posts
    677
    Typing Rundll32 User,ExitWindows (or something like that... I can't remember it exactly) into the Run command works, so with the right header file (system.h i think) you can use the ShellExecute command:

    Code:
    #include <system.h>
    ...
    ...
    ShellExecute(this->Handle,"open","rundll32 User,ExitWindows",NULL,"",SW_SHOWNORMAL);
    ...
    ...
    I think its User,ExitWindows. Try User32 if User doesn't work... I can't remember the exact contect of the command... but that's one way of shutting down a system from C++ (Or from the Run command, and hence from a .LNK shortcut file as well, should the need arise).
    One Ring to rule them all, One Ring to find them.
    One Ring to bring them all and in the darkness bind them.
    (The Lord Of The Rings)
    http://www.bytekill.net

  3. #3
    Member
    Join Date
    Dec 2001
    Posts
    94
    i don't think this'll run under borland 3.0

    i might be wrong though. thanks anyways i'll chk it out later rightnow im in no mood of programming.

    any other suggestions are welcome...

  4. #4
    Senior Member
    Join Date
    Mar 2002
    Posts
    442
    Not sure if this will help you or not but. . .
    Here is how you can make rundll shutdown you windoze machine. You can paste this line into a short cut and run it manually or you can execute it through C++. Here is the link { C:\windows\rundll.exe user.exe,exitwindowsexec }

  5. #5
    AO French Antique News Whore
    Join Date
    Aug 2001
    Posts
    2,126
    Like The3ntropy said, you don't need C++ to shutdown Win98, just make a shortcut and enter { C:\windows\rundll.exe user.exe,exitwindowsexec } for target. The Shortcut will shutdown your computer.
    -Simon \"SDK\"

  6. #6
    Member
    Join Date
    Dec 2001
    Posts
    94
    well i should have maybe told more..

    i want to make a c++ program that can shutdown the sys after 3 wrong passwords have been entered.

    i can make a program that can restart the computer if 3 wrong paswords have been entered but whats the use of that.

    so does anyone know how to...

  7. #7
    Senior Member
    Join Date
    Oct 2001
    Posts
    677
    How have you been getting it to restart, what code do you use for that?
    One Ring to rule them all, One Ring to find them.
    One Ring to bring them all and in the darkness bind them.
    (The Lord Of The Rings)
    http://www.bytekill.net

  8. #8
    Member
    Join Date
    Dec 2001
    Posts
    94
    thanks to Bubba at www.cprogramming.com, maybe i'll ask him again

    To reboot the system:

    outp(0x64,0xFE);

    This will only work if you are in pure DOS (Windows catches this) and if the keyboard buffer is not full. In DOS this will work 99% of the time since the keyboard buffer being full is a rare occurrence
    .

  9. #9
    Senior Member
    Join Date
    Oct 2001
    Posts
    677
    Did you want to shutdown from DOS, or Windows?

    The code I posted above will only work in Windows, as far as I know. As for shutting down from DOS, I don't know any code off the top of my head.
    One Ring to rule them all, One Ring to find them.
    One Ring to bring them all and in the darkness bind them.
    (The Lord Of The Rings)
    http://www.bytekill.net

  10. #10
    Member
    Join Date
    Dec 2001
    Posts
    94
    >>Did you want to shutdown from DOS, or Windows?

    yeah it was from dos,

    >>As for shutting down from DOS, I don't know any code off the top of my head.

    well, ok thanks for replying anyway, let me know if you get to know something.

Posting Permissions

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