Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a CD in the drive? 1

Status
Not open for further replies.

OriginXYZ

Programmer
Jun 21, 2001
8
0
0
US
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
 
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

 
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
 
Hello,

it seems direct disk I/O is possible, according to 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)
A source for a file manager is in the source-code section, last page (Win32asm File Manager)
I hope this helps you a bit further.
Wouter Dijkslag

 
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
 
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

 
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
 
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
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top