944,111 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Mar 21st, 2006
0

Restarting the Computer

Expand Post »
I'm new here, as you can most likely tell by my low post count... but my question is simple. What procedure/commands/whatever would I need to make the computer restart or shutdown? I have google'd for a looooong time to find this, but found absolutely nothing. Does anyone have some help for me? Its confusing
Thanks for all help!
EDIT:
Using borland pascal 7... if that makes any difference.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DarknessX is offline Offline
5 posts
since Mar 2006
Mar 21st, 2006
0

Re: Restarting the Computer

You'll need to use the windows API with Pascal...I found this site: http://www.irietools.com/iriepascal/progref305.html, but it's about Irie pascal and not turbo pascal.... I'm not sure the difference. Basically, you need to figure out how to call functions of the windows library's (the windows dll's) with pascal. Then you can use the exitwindows or exitwindowsex API call.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Mar 22nd, 2006
0

Re: Restarting the Computer

Hi,

I had post a code snippet about this lately on the code snippets section of this site. Check on Pascal, Delphi code snippets w/ my nick "Lord Soth".

Loren Soth
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Mar 22nd, 2006
0

Re: Restarting the Computer

As mentioned in prev post you need to call the InitiateSystemShutdown funtion.
Its a windows function, its declared in the Windows unit.

Before you can call it succesfully though you need to get the right priviliges.
Look at:

http://msdn.microsoft.com/library/de...emshutdown.asp
http://msdn.microsoft.com/library/de...dialog_box.asp

HTH
Reputation Points: 10
Solved Threads: 0
Newbie Poster
frunnik is offline Offline
3 posts
since Mar 2006
Mar 22nd, 2006
0

Re: Restarting the Computer

The below program is meant to be used as a login script that you must use, it is for another program I made... it all works fine, but I did edit this program to remove passwords and etc... so anything that cannot be done logged off, won't work.
Thanks for any and all help, including the help I was given earlier.

Pascal and Delphi Syntax (Toggle Plain Text)
  1. Program StartUpAuth;
  2. uses dos;
  3. uses Reboot;
  4. const
  5. pwrd = 'd347h3464';
  6. usrname = 'DarknessX';
  7. var
  8. cmd: String;
  9. s: String;
  10. username: String;
  11. password: String;
  12. Procedure Shut_Down_Windows;
  13. begin
  14. writeln('DarknessX Authentication Server');
  15. writeln('Please type your username.');
  16. readln(username);
  17. if usrname = username then
  18. begin
  19. writeln('Please type your password now.');
  20. readln(password);
  21. if pwrd = password then
  22. writeln(' Verifying...');
  23. end;
  24. begin
  25. if username <> 'DarknessX' then
  26. writeln('Sorry. No cheating the system...');
  27. RebootMach;
  28. if password <> 'd347h3464' then
  29. writeln('Sorry. No cheating the system...');
  30. RebootMach;
  31. end;
  32. writeln('Welcome to the WinXP Command Line Interface.');
  33. writeln('Please type "help" for a list of commands.');
  34. writeln('If you wish to skip this, please type "exit"');
  35. writeln('CMD..');
  36. read(cmd);
  37. write(cmd);
  38. if cmd <> 'exit' then
  39. writeln('Sorry, this command line interface has no extra commands available');
  40. if cmd = 'help' then
  41. writeln('The WinXP CLI, made by DarknessX, currently has no features.');
  42. writeln('The only feature it has is Authentication.');
  43. if cmd = 'exit' then
  44. end;
  45. end.
One error occurs with this, and that is if I use both Uses dos; and uses Reboot; then it won't compile- it tells me that its supposed to have a begin between the uses dos; and the uses Reboot;... Any reason why?
other than that, this program compiles fine, and seems to work fine, aswell. However, if I enter the wrong login details, it simply freezes. I have the required files for my shutdown procedure, and I believe it works, but... It just doesn't want to work for me.. Like I said above, it simply freezes.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DarknessX is offline Offline
5 posts
since Mar 2006
Mar 23rd, 2006
0

Re: Restarting the Computer

Hi,

It seems like on Procedure Shut_Down_Windows; There isn't enough end to match the begins. (2 begins vs 1 end) Other than that try "uses dos,Reboot;"

Loren Soth
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Mar 23rd, 2006
0

Re: Restarting the Computer

Oh! I forgot to remove the procedure Oops. But is there any other reason why it might just freeze up instead of restarting me?
And the procedure was from a different attempt at trying to turn delphi into it, but it didn't work so well...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DarknessX is offline Offline
5 posts
since Mar 2006
Mar 24th, 2006
0

Re: Restarting the Computer

Hi,

This one works on Delphi :

Pascal and Delphi Syntax (Toggle Plain Text)
  1. program Project2;
  2. {$APPTYPE CONSOLE}
  3. uses SysUtils;
  4.  
  5. //Use upper case constants as a convention
  6. const PWRD = 'd347h3464';
  7. USRNAME = 'DarknessX';
  8. VER = '1.0';
  9.  
  10. var cmd: String;
  11. username: String;
  12. password: String;
  13.  
  14. begin
  15. writeln('DarknessX Authentication Server');
  16. write('username : ');
  17. readln(username);
  18. write('password : ');
  19. readln(password);
  20. writeln(' Verifying...');
  21.  
  22. if username <> USRNAME then begin
  23. While true do write('Sorry. No cheating the system...');
  24. //RebootMach;
  25. end;
  26.  
  27. if password <> PWRD then begin
  28. While true do write('Sorry. No cheating the system...');
  29. //RebootMach;
  30. end;
  31.  
  32. writeln('Welcome to the WinXP Command Line Interface.');
  33. writeln('Please type "help" for a list of commands.');
  34. writeln('If you wish to skip this, please type "exit"');
  35. writeln('CMD..');
  36. While true do Begin
  37. Write('>');
  38. readln(cmd);
  39. if cmd = 'help' then begin
  40. writeln('The WinXP CLI V'+VER+' - by DarknessX.');
  41. writeln('Supported commands :');
  42. writeln(' help');
  43. writeln(' ver');
  44. writeln(' exit');
  45. end else if cmd = 'ver' then Begin
  46. writeln('WinXP CLI V'+VER+' - by DarknessX');
  47. end else if cmd = 'exit' then Begin
  48. exit;
  49. end else writeln('Unrecognized command. Try help.');
  50. end;
  51. end.

Loren Soth
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Mar 24th, 2006
0

Re: Restarting the Computer

Thank you!!! I Praise you!! That was exactly what I needed!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DarknessX is offline Offline
5 posts
since Mar 2006
Mar 26th, 2006
0

Re: Restarting the Computer

Couldn't find the edit button.. but my problem still isn't solved. I don't have a delphi compiler, and don't know how to get one free without resorting to warez which I prefer to not do... and I cant find anything on a free delphi compiler. That code doesn't work in pascal, it won't even compile.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DarknessX is offline Offline
5 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: FindFirst / FindNext problem
Next Thread in Pascal and Delphi Forum Timeline: reverse the strings





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC