First you have to check if MSCDEX is installed.
This is all in assembly, but it is not to hard to port to C or to do
it inline. Make sure to preserve DS, just in case I forgot to, in functions that alter it or C will crash.
I would personally write this in a separate assembly source file and then call out to it from C. If you need help on setting that up, let me know.
;if we get here MSCDEX is installed
To get the version of MSCDEX
;BH holds major version
;BL holds minor version
To do anything you have to know how many CD-ROMS are present
Now you need to get the name of the CD-ROM device driver
xor BX,BX ;same as mov bx,0
;BX holds number of CD-ROMS
;CL holds first drive's letter (0=A,1=B, etc.)
;Cannot be used with DOS 4.0 GRAPHICS.COM
You will need a buffer that is 5 times the number of drives present (in bytes).
Now to get a file handle to the device
FileHandle can be retrieved via DOS function 3Dh
Now you can check the CD-ROM status
mov dx, SEG Array ;our file name is the device driver
push ds ;even for inline asm - DS must be pushed
mov dx,OFFSET Array
mov al,002h ;open file for read/write
mov ah,3Dh ;open file with handle
pop DS ;restore DS so C or asm can continue normally
;handle will be in AX
You will need a 5 byte block of memory.
bit 10 is set if audio is playing
mov dx,SEG Buffer
push ds ;Save DS
mov dx,OFFSET buffer
pop DS ;Restore DS
bit 9 is set if Red Book and HSG addressing are supported
bit 8 is set if audio channel control is supported
bit 7 is set if prefetch requests are supported
bit 5 is set if interleaving is supported
bit 4 is set if audio/video playback supported
bit 3 is set if the CD-ROM is writable
bit 2 is set if raw and cooked read is supported
bit 1 is set if door is unlocked
bit 0 is set if door is open
Hope this helps.