Chinaunix首页 | 论坛 | 博客
  • 博客访问: 330645
  • 博文数量: 64
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 589
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-08 15:50
文章分类

全部博文(64)

文章存档

2015年(52)

2014年(3)

2013年(9)

我的朋友

分类: LINUX

2015-05-13 17:40:59

弹出光驱     

#include
#include
#include
#include
#include
#define DEVICE "/dev/cdrom"
int fd = open(DEVICE, O_RDONLY|O_NONBLOCK);
  if (fd < 0) {
    perror("unable to open "DEVICE);
    exit(1);
  }
  if (ioctl(fd, CDROMEJECT) != 0) {
    perror("CDROMEJECT ioctl failed");
    exit(1);
  }
  if (close(fd) != 0) {
    perror("unable to close "DEVICE);
    exit(1);
  }
2. [代码]收回光驱     
#include
#include
#include
#include
#include
#define DEVICE "/dev/cdrom"
int fd = open(DEVICE, O_RDONLY|O_NONBLOCK);
  if (fd < 0) {
    perror("unable to open "DEVICE);
    exit(1);
  }
  if (ioctl(fd, CDROMCLOSETRAY,0) != 0) {
    perror("CDROMCLOSETRAY ioctl failed");
    exit(1);
  }
  if (close(fd) != 0) {
    perror("unable to close "DEVICE);
    exit(1);
  }


阅读(1266) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~