Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing "Insert diskette to drive X:"

I am trying to check does any disk is present in drive A: (after my program installs i need to ensure that computer won't boot from installation diskette). I've tried using _access method (undefined reference...), FILE* and making directory inside diskette and remove it after checking. Unfortunately DOS displays ugly piece of text about putting disk in drive (Destroying my TUI and making user think that diskette in drive is important). So how to suppress this message, or safely check does disk is present in drive?

like image 519
Kamila Szewczyk Avatar asked May 08 '17 14:05

Kamila Szewczyk


2 Answers

Possibly BIOS INT 13H 16H: Detect Media Change - it has a status:

80H = diskette drive not ready or not installed

Which may solve your problem - I lack the antique hardware and software to test it personally.

#include <dos.h>

unsigned int DetectMediaChange()
{
    union REGS regs;

    regs.h.ah = 0x16;            // Detect Media Change
    regs.h.dl = 0;               // Drive A
    int86( 0x13, &regs, &regs ); // BIOS Disk I/O INT 13h

    return regs.h.ah ;           // Status :  00H = diskette change line not active
                                 //           01H = invalid drive number
                                 //           06H = either change line is not supported or
                                 //                 disk change line is active (media was swapped)
                                 //           80H = diskette drive not ready or not installed
                                 // else= BIOS disk error code if CF is set to CY
}
like image 177
Clifford Avatar answered Oct 19 '22 14:10

Clifford


Okay, I've figured it out:

char far * bufptr;
union REGS inregs, outregs;
struct SREGS segregs;
char buf [1024];
avaliable(){
    redo:
    segread(&segregs);
    bufptr = (char far *) buf;
    segregs.es = FP_SEG(bufptr);
    inregs.x.bx = FP_OFF(bufptr);
    inregs.h.ah = 2;
    inregs.h.al = 1;
    inregs.h.ch = 0;
    inregs.h.cl = 1;
    inregs.h.dh = 0;
    inregs.h.dl = 0;
    int86x(0x13, &inregs, &outregs, &segregs);
    return outregs.x.cflag;
}

Returns true if disk is in drive.

like image 23
Kamila Szewczyk Avatar answered Oct 19 '22 15:10

Kamila Szewczyk