Suppressing "Insert diskette to drive X:"
Asked Answered
A

2

6

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?

Adlare answered 8/5, 2017 at 14:17 Comment(13)
What year is it?Quadruplicate
Now I know the time machine was invented in 80s-90s od XXs century and was based on DOS computer...Novobiocin
Anyone has no idea how to solve it?Adlare
If you asked me 20 years ago I would have known it :)Vastha
isn't there a retrocomputing site on SO? you may have better luck there (still on-topic on SO until they burninate MS-DOS tag though)Siloa
Is it an 8" or 5" drive? :))Kan
3 1/2" drive ...Adlare
why do you need to write a new program in DOS? in many cases retrocomputing.stackexchange.com would provide better resultsChiropractor
@LưuVĩnhPhúc If i would post same question on retrocomputing, wouldn't it be bad?Adlare
You'd have the same problem on USB sticks. Can you change the BIOS so that it does not boot from removable media?Handkerchief
Please enlighten me how can in modify bios using CAdlare
@KrzysztofSzewczyk : He clearly intended "change the BIOS configuration, not the BIOS itself". It is probably simplest to instruct the user to remove the installation disk and expect them to do it; after all even if you detected removal, you cannot prevent reinsertion at any time after. In principle it is the user's PC; if you changed the BIOS configuration programatically I'd be very concerned if it were my PC - that is not your business. Besides such a feature is not standard - different BIOS manufacturers may implement boot sequencing differently.Bilk
I had the same problem with a punch tape reader a while back...Pinchpenny
A
1

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.

Adlare answered 8/5, 2017 at 15:48 Comment(0)
B
1

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
}
Bilk answered 8/5, 2017 at 14:53 Comment(12)
So if disk is not in drive will return 06h?Adlare
@KrzysztofSzewczyk : I have added C code; but it is derived from antique code found on the Internet for other DOS/BIOS services; I have not tested it. Whether it works on a virtual machine depends entirely on the completeness of the virtualisation; since the BIOS is probably fundamental to may things working, one would imagine that it is complete and would therefore work. For you to try, not me to know.Bilk
@KrzysztofSzewczyk : What makes you think that? I would imagine 0x80 as per the comment and the link referenced. But it depends what "not ready" means I guess - it is rather poorly documented. 0x06 occurs I believe when the "door" is operated (disk insert, possibly disk eject, but you would hope 0x80 would prevail in that event). I suggest you are in the best position to try this and care more than I do. Just suck it and see!Bilk
Okay. I've inserted disk and it returned 6, took disk and returned 6. Broken.Adlare
The "changed" status is only reset to zero on a valid disk access, so insert, access, eject. However you would get that result too if you ejected and immediately reinserted. Also "change line is not supported" is an allowed option and would generate that result - not "broken", just not implemented, or does not do what you need. I had hoped for a 0x80 on no media.Bilk
That's okay then, but i need real-time information about diskette is inserted, "at the moment".Adlare
If you can, simpler perhaps to prevent diskette media booting in the BIOS configuration.Bilk
from my place it's impossible. I've heard about an interrupt that can disable it. I'll check out what exactly interrupt is itAdlare
Sorry that was by best stab and software archaeology - I have nothing more for you at present. I doubt you can disable it from an S/W interrupt since it occurs on boot up - it needs a modification of the battery backed CMOS memory containing the BIOS configuration (and may not even be supported).Bilk
I think Int 2F/4A00 relates to swapping drive A/B on a single floppy machine. I am not sure how that will solve your problem.Bilk
"Called by MS-DOS 5.0+ IO.SYS just before displaying the message "Insert diskette for drive X:" on single-floppy systems" and "FFFFh to skip "Insert diskette for drive X:" message"Adlare
Yes but it still refers to "logical" not "physical" drives. See blogs.msdn.microsoft.com/oldnewthing/20090402-00/?p=18643 if it could not be done in Win95, I am pretty sure it was not a feature of MS-DOS either.Bilk
A
1

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.

Adlare answered 8/5, 2017 at 15:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.