×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Is there a CD in the drive?

Is there a CD in the drive?

Is there a CD in the drive?

(OP)
Im trying to write a windows explorer type app for DOS. I was going fine until I hit the no disc in drive problem...if it were a HD, you could just check to see if it was a valid drive. But it IS a valid drive, I just cant tell the program that the drive is empty! :)

If anyone can help on this, id appreciate it

OriginXYZ

RE: Is there a CD in the drive?

(OP)
wow...I stumped you all

RE: Is there a CD in the drive?

Hello,

I didn't see your message before
I assume you are trying to read a floppy-drive, I have not tested this with other drives, but it should work also.
Just read one sector of it, and if it returns without errors, there is a disk, and if there is an error, no disk.
Check out Ralf Brown's interrupt list, interrupt 13 function 2(both hex)

something like:
        mov     ax,201h
        push    ds
        pop     es
        mov     bx,temp_buffer
        mov     cx,1
        mov     dx,0
        int     13h

Wouter Dijkslag
 
http://www.wody.demon.nl
 

RE: Is there a CD in the drive?

(OP)
accually no :(

I am trying to write a Windows Explorer type Program.
I can detect all drives for exsistance already.
But If you try ANY file or disk opperation when there is not a disc
in the CD-ROM the program crashes. (The drive is there, but there is no media).

I have not had any luck finding code for the CD-ROM. Except for the FAQ v1 or v2, and that is pretty hard to follow. Also none of the standard commands for hard disks (INT 13, INT 15, or INT 21) seem to be able to solve this problem either.

Please Help :)

OriginXYZ

RE: Is there a CD in the drive?

Hello,

it seems direct disk I/O is possible, according to http://www.hammick.com/hcs/diskio.asm
But if a program crashes like this it seems something is wrong.
I don't know what you are trying to do, but for me a simple FindFirstFile works fine, on any drive, with or without media. (Giving error-status where appropiate offcourse)
http://msdn.microsoft.com/library/en-us/fileio/hh/winbase/filesio_4qcl.asp
A source for a file manager is www.win32asm.cjb.net in the source-code section, last page (Win32asm File Manager)
I hope this helps you a bit further.

Wouter Dijkslag
 
http://www.wody.demon.nl
 

RE: Is there a CD in the drive?

(OP)
Thank you for the reply :)
This did not help much :( these pages are for Win32 ?
Im still in DOS :) (trying to replace DOS, accually)
If I am missing a DOS section from those links please let me know, but I did not see anything.

Thank You for the Effort :)

OriginXYZ

RE: Is there a CD in the drive?

Hello,
One of these days I'm going to have to learn how to read
To check wether a drive is empty or not, we have to do some disk operation, like GetCurrentDirectory(Int 21 function 47) on it.
However, if we do this on an empty drive, DOS will intercept with an error-message and prompt for a reply (For instance Disk not ready reading drive A, Abort, Retry, Fail, Take over rest of world?)
The piece of code actually giving that message is called the Critial error handler. But we do not want to have this kind of interference. So what we do is, replace the critical error handler, try int 21 fnc 47 and if that fails, indicate no drive is present. After testing, we can then put the original error handler back.
There are some sources out there for critical error handlers, but basically all that has to be done is set ax to 3, and iret out of there.
Things to check out:
Int 21 function 25 (Set interrupt vector)
Int 21 function 47 (Read Active Directory)
Int 24 (Critical Error Handler)

Hope this helps,

Wouter Dijkslag
 
http://www.wody.demon.nl
 

RE: Is there a CD in the drive?

(OP)
Awesome! :) Thank you very much....Im not sure I know how to code it yet, but I understand it :) thats a start. Ive never played with replacing handlers/drivers. Im very interested in it, but im not sure im ready to play with it yet. I will obviously have no choice in this case, however ;)


Thanks again
OriginXYZ

RE: Is there a CD in the drive?

Hello,
Here is some source. Note that the error-handler is not uninstalled, but automaticly removed when DOS gets control back.
Also, it always returns fail, which is bad programming, and only works on dos v3 and up. Some more details of how it should behave at http://www.htl-steyr.ac.at/~_morg/pcinfo/hardware/interrupts/inte8iuo.htm

install_critic  PROC
                push ds
                push cs
                pop ds
                mov dx,offset critical_error
                mov ax,2524h ; replace int 24h
                int 21h
                pop ds

                ret
install_critic  ENDP

critical_error  PROC FAR
                mov al,3; always fail (dos 3+)
                iret
critical_error  ENDP

Wouter Dijkslag
 
http://www.wody.demon.nl
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close