Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How to eject a CD in code?

In C code, how do I eject a CD (for example, D: drive)?

2 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    There is a way to do it with API. This is for vb, but check it out.

  • Anonymous
    1 decade ago

    There is no CMD eject command, not that I would know of. If you want this so you can make a batch script, you could use this VBScript:

    Set oWMP = CreateObject("WMPlayer.OCX.7" )

    Set colCDROMs = oWMP.cdromCollection

    if colCDROMs.Count >= 1 then

    For i = 0 to colCDROMs.Count - 1

    colCDROMs.Item(i).Eject

    Next ' cdrom

    End If

    And than in a bat/cmd file:

    @echo off

    wscript.exe 0%\..\filename.vbs

    taskkill /F /IM wscript.exe

    EXIT

    Too bad the .vbs script doesn't stop running lol

Still have questions? Get your answers by asking now.