Restarting the Computer

Reply

Join Date: Mar 2006
Posts: 5
Reputation: DarknessX is an unknown quantity at this point 
Solved Threads: 0
DarknessX DarknessX is offline Offline
Newbie Poster

Restarting the Computer

 
0
  #1
Mar 21st, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Restarting the Computer

 
0
  #2
Mar 21st, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Restarting the Computer

 
0
  #3
Mar 22nd, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 3
Reputation: frunnik is an unknown quantity at this point 
Solved Threads: 0
frunnik frunnik is offline Offline
Newbie Poster

Re: Restarting the Computer

 
0
  #4
Mar 22nd, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 5
Reputation: DarknessX is an unknown quantity at this point 
Solved Threads: 0
DarknessX DarknessX is offline Offline
Newbie Poster

Re: Restarting the Computer

 
0
  #5
Mar 22nd, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Restarting the Computer

 
0
  #6
Mar 23rd, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 5
Reputation: DarknessX is an unknown quantity at this point 
Solved Threads: 0
DarknessX DarknessX is offline Offline
Newbie Poster

Re: Restarting the Computer

 
0
  #7
Mar 23rd, 2006
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...
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Restarting the Computer

 
0
  #8
Mar 24th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 5
Reputation: DarknessX is an unknown quantity at this point 
Solved Threads: 0
DarknessX DarknessX is offline Offline
Newbie Poster

Re: Restarting the Computer

 
0
  #9
Mar 24th, 2006
Thank you!!! I Praise you!! That was exactly what I needed!
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 5
Reputation: DarknessX is an unknown quantity at this point 
Solved Threads: 0
DarknessX DarknessX is offline Offline
Newbie Poster

Re: Restarting the Computer

 
0
  #10
Mar 26th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC