建立CD-ROM工具箱
1.检验CD-ROM扩充是否装入
#include<stdio.h>
#include<dos.h>
union REGS regs;
struct SREGS sregs;
int test()
{
regs.x.ax=0x1100;
int86x(0x2f,®s,®s,&sregs);
if (regs.h.a1 !=0xff) {
printf ("CD-ROM not found.\n\r");
return -1;
}
else {
printf ("Found CD-ROM.\n\r");
return 0;
}
}
2.获取CD-ROM驱动器个数
#include<stdio.h>
#include<dos.h>
union REGS regs;
struct SREGS sregs;
int get-cnt()
{
regs.x.ax=0x1500;
regs.x.bx=0;
int86(0x2f,®s,®s);
return (regs.x.bx);
}
3.按物理扇区读光盘
#include<stdio.h>
#include<dos.h>
union REGS regs;
struct SREGS sregs;
unsigned bufseg;
int read-sec()
{
if (allocmem(4096,&bufseg) !=-1) {
printf ("No sufficient memory.\n\r");
return -2;
}
regs.x.ax=0x1508;
regs.x.bx=0;
sregs.es=bufseg;
regs.x.dx=1;
regs.x.si=0;
regs.x.di=0x10;
int86x(0x2f,®s,®s,&sregs);
if (regs.x.cflag) {
printf ("Read Error.\n\r");
return -1;
}
else return (0);
}
4.取MSCDEX.EXE主版本号
#include<dos.h>
union REGS regs;
int get-ver()
{
regs.x.ax=0x150c;
int86(0x2f,®s,®s);
return(regs.h.bh);
}
程序用TC 2.0编写,读者可以将其嵌入自己的程序,或将该程序编译后扩充到标准库中直接调用其中的函数。