Thread: how can I reboot system,with one line c++ code?

  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    5

    Question how can I reboot system,with one line c++ code?

    hi
    please help me.
    I need a short C++ code for reboot system(only c++)
    can I do it?
    thanks a lot

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I'm assuming you did some research on this before asking. What information did you find when you entered, say, "c++ reboot" into your search engine of choice?

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    5
    Quote Originally Posted by Matticus View Post
    I'm assuming you did some research on this before asking. What information did you find when you entered, say, "c++ reboot" into your search engine of choice?
    I test every codes I find in internet.
    but none of them,does not work!
    it impossible or possible?
    I'm so sorry for my bad EN.

  4. #4
    Registered User
    Join Date
    Jun 2012
    Location
    Morden, UK
    Posts
    128
    Controlling the computer with C++ - C++ Forum

    Could try this? A quick google search found that one.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Perhaps you could show a bit of code you've tried that doesn't work (making sure your code is posted in code tags). You should also include your compiler and OS.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by samwillc View Post
    Controlling the computer with C++ - C++ Forum

    Could try this? A quick google search found that one.
    Best pay no heed to that link.
    system is bad for many reasons, among them nonportable and a security risk.
    Furthermore, there are other bad practices there, such as gets.

    Rebooting a computer is not done in a single line and depends on your OS.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jun 2012
    Location
    Morden, UK
    Posts
    128
    The point was more about how easy it is to find info on google. However, the risks of that have just been exposed!

  8. #8
    Registered User
    Join Date
    Apr 2013
    Posts
    5
    why i can't do this project
    I test every code,but it'll dose not work.
    can you upload cpp file code?

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Once again, what operating system?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    Apr 2013
    Posts
    5
    Quote Originally Posted by Elysia View Post
    Once again, what operating system?
    not different...
    windows XP or 7 or both of them.
    thank's.

  11. #11
    Registered User
    Join Date
    Apr 2013
    Posts
    5
    I find a short code
    I test it without any include and worked.but could not reboot system.I think this code have a little problem but it possible.please test this code and if you can find problem,say me too.
    sorry again for my bad EN.

    Code:
    void main(){    (*(void (far *)(void))0xffff0000L)();}

  12. #12
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by dvbhot View Post
    I find a short code
    I test it without any include and worked.but could not reboot system.I think this code have a little problem but it possible.please test this code and if you can find problem,say me too.
    sorry again for my bad EN.

    Code:
    void main(){    (*(void (far *)(void))0xffff0000L)();}
    Are you trying to shutdown the computer? Or are you trying to crash the computer?

    InitiateSystemShutdownEx function (Windows)

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  13. #13
    Registered User
    Join Date
    Apr 2013
    Posts
    1,658
    You can follow this small thread from msdn forums:

    msdn_reboot.htm

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    In other words, crappy DOS only 1-line tricks.

    Mostly, you're just another script kiddie wannabe who thinks programming is trying to muck about with other peoples machines.

    People genuinely interested in programming do not ask "how do I reboot...." as their first thread, and then proceed to recycle some stupid DOS code they found on the net.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading a buffer line by line, while using system read
    By Hammad Saleem in forum C Programming
    Replies: 9
    Last Post: 05-27-2008, 05:41 AM
  2. Getting last system reboot time - C
    By Markallen85 in forum Windows Programming
    Replies: 3
    Last Post: 08-22-2003, 12:32 PM
  3. Reboot example
    By [SuRaNa] in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2002, 05:00 PM
  4. Reboot
    By Commander in forum C Programming
    Replies: 6
    Last Post: 09-24-2001, 12:41 PM