Thread: check CD-ROM status...?????

  1. #1
    Registered User Sunny's Avatar
    Join Date
    Nov 2001

    Unhappy check CD-ROM status...?????

    Heya all ppl!!

    Anyone here know how to check the status of the CD-ROM? I mean, like if there is a cd inside or if it's ejected...???

    Ok, thanks a lot

  2. #2
    I'm Back
    Join Date
    Dec 2001
    theres a biosdisk() in bios.h. i haven't used it just read about it so can't really help you right now.

    that's if you want to use it while like in programming.

    otherwise whats wrong with using the d: or your driveletter command??
    Last edited by ihsir; 02-25-2002 at 09:21 AM.

  3. #3
    Join Date
    Aug 2001
    Groningen (NL)
    Isn't it in the documentation of your driver? I think you need to send a command to the driver and interpret the result it sends back. Sending a command to the driver is in this case calling a driver function which retrieves the status of the CD-ROM device.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    You can access the CD-ROM via the multiplex interrupt 2Fh.

    For more information consult Ralf Brown's Interrupt Listing. You will also have to use DOS IOCTL via int 21h to issue IO commands to the drive for things such as opening the door and closing the door.

  5. #5
    Registered User Sunny's Avatar
    Join Date
    Nov 2001


    Thanks. I found out it's a LOT more complicated than i thought.
    I found some interesting documentation at BUt it's still very hard to check the drive status.

    The ideal would be to know if it's ejected, closed or if there's a CD inside and all that.

    Thanks a lot everybody!!!!

    Yes...YES!!! I did it! Ha ha ha...I'm king of the world...No..No..please-wait-no...!!!!-- This program has performed an illegal operation AND WILL be shut

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    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.

    mov AX,0DADAh
    push AX
    mov AX,01100h
    int 2Fh
    pop BX
    cmp BX,0ADADh
    jne NOTFOUND
    ;if we get here MSCDEX is installed

    To get the version of MSCDEX
    mov AX,0150Ch
    int 2Fh
    ;BH holds major version
    ;BL holds minor version

    To do anything you have to know how many CD-ROMS are present
    mov AX,01500h
    xor BX,BX            ;same as mov bx,0
    int 2Fh
    ;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
    Now you need to get the name of the CD-ROM device driver
    You will need a buffer that is 5 times the number of drives present (in bytes).
    mov AX,01501h
    les  BX,Array
    int 2Fh
    Now to get a file handle to the device
    FileHandle can be retrieved via DOS function 3Dh
    mov dx, SEG Array     ;our file name is the device driver
    push ds                     ;even for inline asm - DS must be pushed 
    mov ds,dx
    mov dx,OFFSET Array
    mov al,002h          ;open file for read/write
    mov ah,3Dh          ;open file with handle
    int 21h
    jc error_encountered
    mov FileHandle,ax
    pop DS                 ;restore DS so C or asm can continue normally
    ;handle will be in AX
    Now you can check the CD-ROM status
    You will need a 5 byte block of memory.
    mov bx,FileHandle
    mov cx,MaxBytes
    mov dx,SEG Buffer
    push ds                       ;Save DS
    mov ds,dx
    mov dx,OFFSET buffer
    mov ax,04402h
    int 21h
    jc error_encountered
    mov BytesReceived,ax
    pop DS                        ;Restore DS
    bit 10 is set if audio is playing
    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.

  7. #7
    Registered User Sunny's Avatar
    Join Date
    Nov 2001

    Talking Thanks

    Thanks a lot. It sure does help.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to put a check on an extern variable set as flag
    By rebelsoul in forum C Programming
    Replies: 18
    Last Post: 05-25-2009, 03:13 AM
  2. MFC check box question
    By MyglyMP2 in forum Windows Programming
    Replies: 2
    Last Post: 03-09-2009, 05:47 PM
  3. Not working in linux...
    By mramazing in forum C++ Programming
    Replies: 6
    Last Post: 01-08-2009, 02:18 AM
  4. allegro issues
    By mramazing in forum C++ Programming
    Replies: 1
    Last Post: 01-07-2009, 11:56 PM
  5. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM