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
Printable View
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
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:
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).Code:#include <system.h>
...
...
ShellExecute(this->Handle,"open","rundll32 User,ExitWindows",NULL,"",SW_SHOWNORMAL);
...
...
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...
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 }
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.
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...
How have you been getting it to restart, what code do you use for that?
thanks to Bubba at www.cprogramming.com, maybe i'll ask him again
.Quote:
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
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.
>>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.
Shutting down, rebooting or logging of can be accomplished in Windows by using ExitWindows or ExitWindowsEx.
These work fine in win9x - but in NT (i.e. Win2k + XP too) you need to faff around with privileges to shut down or reboot.
In windows NT etc, it's far too much effort, you should get a command line program like in the resource kit reboot.exe for you :)
Just RTFM for ExitWindows or ExitWindowsEx (I think)
Mark
i think there is a mizundaztanding
ihsir just want to shut down his dos, but the other think that he want to shut down his windows
the problem is, usually dos cannot doing any auto power off, so if you execute that outport condition, it will do the restarting (i have read one, but it use interrupt)
if the problem, is you want the user of your program cannot use the computer after he fail 3 times,
then you can off the ctrl-break condition, then do a not-end-loop
hope it work
atleast pakdhe you understood about the dos and window confusion ;)
so you say that there's no way closing a system from pure dos mode.
i dont want a 'never-ending' or a 'stop' loop i had that before but it didn't look nice so that's why i want to perform shutdown.
Just get it to ignore all keypresses afrer 3 attempts at login or whatever. The only way round is to reboot or power off. Just have it go to blank screen and not accept any input. Ctrl. Alt. Delete will still work to reboot, of course, unless there's some way of trapping that key sequence and ignoring it... But I think DOS likes to keep hold of that one in case programs go into endless loops and you have to manually reboot?!
there are many ways to trap ctr_alt_delete in dos...
There used to be a 4k proggy to halt my pc... can't remember... well sorry I'm on linux now...
halt