Computer_Dark_Angle
10-07-2009, 08:50 PM
Đoạn code tắt máy viết bằng c++ by Computer_Dark_Angle
#include <conio.h>
#include <iostream.h>
#include <process.h>
#include <dos.h>
#define True 1
#define False 0
typedef int Bool;
//System command.
void Shutdown (Bool );
void Restart (Bool );
void LogOff (Bool );
//Menu Choice
void Menu ();
//Main Function.
int main (){
textcolor (WHITE);
clrscr ();
gotoxy (10,20);
textcolor (RED);
cprintf ("-----Chuong trinh ung dung 1 so lenh he thong.-----");
gotoxy (10,21);
cprintf ("Chuong trinh duoc viet boi Computer_Dark_Angle.");
gotoxy (10,22);
textcolor (YELLOW);
[Only registered and activated users can see links]
textcolor (WHITE);
gotoxy (1,1);
cout <<"\tAuthor : Computer_Dark_Angle\tVersion : 0.0.0\n\n";
[Only registered and activated users can see links]
cout <<"\n\t*****Thank You For Using This Program!*****\n\n";
Menu ();
int Time;
int Choice;
cin >>Choice;
switch (Choice){
case 1 :
cout <<"\n\tCommand Shutdown now is enable ";
cout <<endl<<"\tComputer will shutdown !";
cout <<"\n\tPlease input time (minute) : ";
cin >>Time;
cout <<"\tComputer will shutdown in : ";
gotoxy (29,17);
int Sec;
Time--;
_setcursortype (_NOCURSOR);
while (Time >= 0){
gotoxy (28,17);
clreol ();
cout <<Time<<" : ";
for (Sec = 60;Sec >= 0;Sec--){
cout <<Sec;
delay (1000);
if (Time < 10){
gotoxy (32,17);
clreol ();
}
else {
gotoxy (33,17);
clreol ();
}
}
Time--;
}
Shutdown (1);
break;
case 2 :
cout <<"\n\tCommand Restart now is enable ";
cout <<endl<<"\tComputer will restart !";
cout <<"\n\tPlease input time (minute) : ";
cin >>Time;
cout <<"\tComputer will restart in : ";
gotoxy (29,17);
Time--;
_setcursortype (_NOCURSOR);
while (Time >= 0){
gotoxy (28,17);
clreol ();
cout <<Time<<" : ";
for (Sec = 60;Sec >= 0;Sec--){
cout <<Sec;
delay (1000);
if (Time < 10){
gotoxy (32,17);
clreol ();
}
else {
gotoxy (33,17);
clreol ();
}
}
Time--;
}
Restart (1);
break;
case 3 :
cout <<"\n\tCommand Log off now is enable ";
cout <<endl<<"\tComputer will Log off !";
cout <<"\n\tPlease input time (minute) : ";
cin >>Time;
cout <<"\tComputer will Log off in : ";
gotoxy (29,17);
Time--;
_setcursortype (_NOCURSOR);
while (Time >= 0){
gotoxy (28,17);
clreol ();
cout <<Time<<" : ";
for (Sec = 60;Sec >= 0;Sec--){
cout <<Sec;
delay (1000);
if (Time < 10){
gotoxy (32,17);
clreol ();
}
else {
gotoxy (33,17);
clreol ();
}
}
Time--;
}
LogOff (1);
break;
}
getch ();
return 0;
}
void Menu (){
cout <<"\tMenu Command : "<<endl;
cout <<"\t1.Shutdown computer."<<endl;
cout <<"\t2.Restart computer."<<endl;
cout <<"\t3.Log off computer."<<endl;
cout <<"\t Your Choice : ";
}
//Function above
void Shutdown (Bool Result){
if (Result == False)
cout <<"This command isn't done!";
else{
system ("shutdown -s -t 0");
}
}
void Restart (Bool Result){
if (Result == False)
cout <<"This command isn't done!";
else{
system ("shutdown -r -t 0");
}
}
void LogOff (Bool Result){
if (Result == False)
cout <<"This command isn't done!";
else{
system ("shutdown -l -t 0");
}
}
Anh em cho ư kiến, em c̣n gà lém hihi:monkey21:
#include <conio.h>
#include <iostream.h>
#include <process.h>
#include <dos.h>
#define True 1
#define False 0
typedef int Bool;
//System command.
void Shutdown (Bool );
void Restart (Bool );
void LogOff (Bool );
//Menu Choice
void Menu ();
//Main Function.
int main (){
textcolor (WHITE);
clrscr ();
gotoxy (10,20);
textcolor (RED);
cprintf ("-----Chuong trinh ung dung 1 so lenh he thong.-----");
gotoxy (10,21);
cprintf ("Chuong trinh duoc viet boi Computer_Dark_Angle.");
gotoxy (10,22);
textcolor (YELLOW);
[Only registered and activated users can see links]
textcolor (WHITE);
gotoxy (1,1);
cout <<"\tAuthor : Computer_Dark_Angle\tVersion : 0.0.0\n\n";
[Only registered and activated users can see links]
cout <<"\n\t*****Thank You For Using This Program!*****\n\n";
Menu ();
int Time;
int Choice;
cin >>Choice;
switch (Choice){
case 1 :
cout <<"\n\tCommand Shutdown now is enable ";
cout <<endl<<"\tComputer will shutdown !";
cout <<"\n\tPlease input time (minute) : ";
cin >>Time;
cout <<"\tComputer will shutdown in : ";
gotoxy (29,17);
int Sec;
Time--;
_setcursortype (_NOCURSOR);
while (Time >= 0){
gotoxy (28,17);
clreol ();
cout <<Time<<" : ";
for (Sec = 60;Sec >= 0;Sec--){
cout <<Sec;
delay (1000);
if (Time < 10){
gotoxy (32,17);
clreol ();
}
else {
gotoxy (33,17);
clreol ();
}
}
Time--;
}
Shutdown (1);
break;
case 2 :
cout <<"\n\tCommand Restart now is enable ";
cout <<endl<<"\tComputer will restart !";
cout <<"\n\tPlease input time (minute) : ";
cin >>Time;
cout <<"\tComputer will restart in : ";
gotoxy (29,17);
Time--;
_setcursortype (_NOCURSOR);
while (Time >= 0){
gotoxy (28,17);
clreol ();
cout <<Time<<" : ";
for (Sec = 60;Sec >= 0;Sec--){
cout <<Sec;
delay (1000);
if (Time < 10){
gotoxy (32,17);
clreol ();
}
else {
gotoxy (33,17);
clreol ();
}
}
Time--;
}
Restart (1);
break;
case 3 :
cout <<"\n\tCommand Log off now is enable ";
cout <<endl<<"\tComputer will Log off !";
cout <<"\n\tPlease input time (minute) : ";
cin >>Time;
cout <<"\tComputer will Log off in : ";
gotoxy (29,17);
Time--;
_setcursortype (_NOCURSOR);
while (Time >= 0){
gotoxy (28,17);
clreol ();
cout <<Time<<" : ";
for (Sec = 60;Sec >= 0;Sec--){
cout <<Sec;
delay (1000);
if (Time < 10){
gotoxy (32,17);
clreol ();
}
else {
gotoxy (33,17);
clreol ();
}
}
Time--;
}
LogOff (1);
break;
}
getch ();
return 0;
}
void Menu (){
cout <<"\tMenu Command : "<<endl;
cout <<"\t1.Shutdown computer."<<endl;
cout <<"\t2.Restart computer."<<endl;
cout <<"\t3.Log off computer."<<endl;
cout <<"\t Your Choice : ";
}
//Function above
void Shutdown (Bool Result){
if (Result == False)
cout <<"This command isn't done!";
else{
system ("shutdown -s -t 0");
}
}
void Restart (Bool Result){
if (Result == False)
cout <<"This command isn't done!";
else{
system ("shutdown -r -t 0");
}
}
void LogOff (Bool Result){
if (Result == False)
cout <<"This command isn't done!";
else{
system ("shutdown -l -t 0");
}
}
Anh em cho ư kiến, em c̣n gà lém hihi:monkey21: