Re: CD eject
- Posted by Juergen Luethje <jluethje at gmx.de> Jul 15, 2002
- 468 views
Hi Pete, petelomax <petelomax at blueyonder.co.uk> wrote: <snip> >> I'm wondering if anyone has a code (windows) that will access a CD-ROM >> drive and make it eject.? Thanks! <snip> > Or if you are feeling really brave, and understand what Interrupt 21h > Function 440Dh Minor Code 49h is/how to call it (Juergen Luethje might > know) Below there is code to call it on DOS. It works fine for me on DOS 7.1/WIN 98. > -- I found that at: > http://www.allapi.net/apilist/example.php?example=Eject%20CD This is very interesting for me, because it shows how to call this DOS interrupt function on Win9x/Me. I will have a closer look at it, when I've some more time. > & it does something different for NT/2000 > Pete You always know cool interrupt functions! ) Thanks and best regards, Juergen ------------------------------------------------------------------->8--- eject_media.ex ======================================================================== include machine.e constant REG_LIST_SIZE = 10, CF = 1 function eject_media (integer drive) -- successfully tested with my CD drive (see demo code below , -- maybe also works with a zip drive? sequence reg_list reg_list = repeat(0, REG_LIST_SIZE) reg_list[REG_AX] = #440D -- and_bits(.., #DF) is a upper() function for ASCII values, -- works for all ASCII values {A..Z, a..z} reg_list[REG_BX] = and_bits(drive, #DF) - 'A' + 1 reg_list[REG_CX] = #0849 reg_list[REG_FLAGS] = or_bits(reg_list[REG_FLAGS], 1) reg_list = dos_interrupt(#21, reg_list) if and_bits(reg_list[REG_FLAGS], CF) = 1 then return -1 -- error else return 0 end if end function -- Demo integer i puts(1, "As an esteemed customer of our company, we want to\n" & "give you this handy drinks holder as a present.") i = eject_media('e') ------------------------------------------------------------------->8---