如何用c语言实现关机程序?

marswgj 2002-10-27 04:15:34
如何用c语言实现关机程序?最好有原代码,并给予一定的解释。谢谢!!!
...全文
123 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
waYeah 2002-11-01
  • 打赏
  • 举报
回复
以下程序在TC2.0,纯DOS下调试通过:

#include<stdio.h>
#include<dos.h>

void main( void )
{
union REGS In,Out;

In.x.ax = 0x5300; /*检查是否支持APM*/
In.x.bx = 0x0000;
int86(0x15,&In,&Out);
if( Out.x.cflag != 0)
{
printf("No APM!\n");
exit(0);
}

In.x.ax = 0x5301; /*连接到APM*/
In.x.bx = 0x0000;
int86(0x15,&In,&Out);
if( (Out.x.cflag!=0) && (Out.h.ah!=0x02))
{
printf("Connecting error!\n");
exit(0);
}

In.x.ax = 0x530e; /*通知APM所使用的版本为1.2*/
In.x.cx = 0x0102;
int86(0x15,&In,&Out);
if( (Out.x.cflag != 0)
{
printf("Ver error!\n");
exit(0);
}

In.x.ax = 0x5307; /*实现关机*/
In.x.bx = 0x0001;
In.x.cx = 0x0003;
int86(0x15,&In,&Out);
if( (Out.x.cflag != 0)
{
printf("Shutdown error!\n");
exit(0);
}
}
sjd163 2002-11-01
  • 打赏
  • 举报
回复
C语言没有提供类似的函数。不能关机只能死机。
jerry_tp 2002-11-01
  • 打赏
  • 举报
回复
我也想要一份
E-MAIL:jerry_tpsy@hotmail.com
carbon107 2002-11-01
  • 打赏
  • 举报
回复
不错要用windows的api函数啊
ywchen2000 2002-10-31
  • 打赏
  • 举报
回复
要用到api函数
WaterWalker 2002-10-28
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/792/792776.xml?temp=.1198542
vcanv 2002-10-27
  • 打赏
  • 举报
回复
我也想要!

vcanv@21cn.com

thank you!!!
omale 2002-10-27
  • 打赏
  • 举报
回复
要使用微软的sdK函数。
标准iso的c语言我估计做不到。

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧