『第
4 楼』:
下面的程序是我几年前把一个CD播放器程序缩改成打开、关闭光驱的小程序,送给你玩玩吧。不过有个缺点,只能在纯DOS下运行,在Win9x的DOS窗口下运行时,如果光驱没有光盘是打不开的,但可以关闭。
#include<dos.h>
int ppp=0;
unsigned int cdnum;
char getbuff[11],setbuff[11];
char stop[]={0x0d,0,0x85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
char setcd[]={0x1a,0,0x0c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
char getcd[]={0x1a,0,0x03,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
main()
{int i; char ch;
_BX=0;
_AX=0x1500;
geninterrupt(0x2f);
if(ppp==0){cdnum=_CX;ppp=1;}
_AX=FP_OFF(getbuff);
_BX=FP_SEG(getbuff);
getcd[0x0e]=_AL;
getcd[0x0f]=_AH;
getcd[0x10]=_BL;
getcd[0x11]=_BH;
_AX=FP_OFF(setbuff);
_BX=FP_SEG(setbuff);
setcd[0x0e]=_AL;
setcd[0x0f]=_AH;
setcd[0x10]=_BL;
setcd[0x11]=_BH;
for(i=0;i<2;i++)
{
getcd[0x12]=5;
getbuff[0]=0x06;
_ES=FP_SEG(getcd);
_BX=FP_OFF(getcd);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
}
ch=getbuff[1]&0x01;
if(ch==0)i=0;
else i=1;
if(i==0)
{_ES=FP_SEG(stop); /*Stop CD*/
_BX=FP_OFF(stop);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
setcd[0x12]=1; /*Open CD*/
setbuff[0]=0;
_ES=FP_SEG(setcd);
_BX=FP_OFF(setcd);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
}
else
{ /*Close CD*/
setcd[0x12]=1;
setbuff[0]=5;
_ES=FP_SEG(setcd);
_BX=FP_OFF(setcd);
_CX=cdnum;
_AX=0x1510;
geninterrupt(0x2f);
}
} [ Last edited by JonePeng on 2006-5-1 at 00:48 ]
|