求一个调用shutdown.exe关机的C++小程序
2个回答
展开全部
其实很简单,其实就是系统调用下shutdown命令就可以了。
程序如下
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
int choice,use=0;
char data[6],ch;
char cmd[]="shutdown -s -t ";
printf("welcome you to use the timeing shutdown application\n");
printf("****************\n");
printf("1 enter the time\n");
printf("2 no operaton and exit\n");
printf("****************\n");
scanf("%d",&choice);
if(choice==1)
{
do
{
printf("please input the time in seconds\n");
scanf("%s",data);
printf("Your computer will shut down in %s seconds\n(Y/N)?",data);
ch=getchar();
ch=getchar();
if(ch=='Y'||ch=='y')
system(strcat(cmd,data));
else
use=1;
} while (use);
}
else
exit(0);
return 0;
}
我空间中写的。
http://hi.baidu.com/huifeng00/blog/item/977dd6537d0c9e838d54300c.html
程序如下
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
int choice,use=0;
char data[6],ch;
char cmd[]="shutdown -s -t ";
printf("welcome you to use the timeing shutdown application\n");
printf("****************\n");
printf("1 enter the time\n");
printf("2 no operaton and exit\n");
printf("****************\n");
scanf("%d",&choice);
if(choice==1)
{
do
{
printf("please input the time in seconds\n");
scanf("%s",data);
printf("Your computer will shut down in %s seconds\n(Y/N)?",data);
ch=getchar();
ch=getchar();
if(ch=='Y'||ch=='y')
system(strcat(cmd,data));
else
use=1;
} while (use);
}
else
exit(0);
return 0;
}
我空间中写的。
http://hi.baidu.com/huifeng00/blog/item/977dd6537d0c9e838d54300c.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询