用C语言写了一个关于关机的小程序,XP系统直接运行达到预期效果了,如果添加一个任务计划来运行这个程序显示的窗口就只有cmd“shutdown”的倒计时窗口,cmd窗口和问“是否关机”的对话框都不显示,请问怎么办才能让对话框显示出来?
下面是代码
#include
#include
#include
int main(void)
{
system("shutdown -s -f -t 10");
int msgboxID = MessageBox(NULL, TEXT("现在关机?"), TEXT("自动关机程序"), MB_ICONASTERISK |MB_TOPMOST| MB_OKCANCEL);
switch (msgboxID)
{
case IDCANCEL:
system("shutdown -a");
MessageBox(NULL, TEXT("请稍后自行关闭电脑"), TEXT("自动关机程序"), MB_TOPMOST|MB_OK);
break;
case IDOK:
system("shutdown -a");
system("shutdown -p -f");
break;
default:
break;
}
return 0;
}