Link to home
Start Free TrialLog in
Avatar of fcp
fcp

asked on

Open and close the "M;" CDROM drive

How to open, in a system with more that one CD/DVD drive/writer, open the one called i.e. "M:"?

I'seen MCISendstring calls, but it uses "CDAudio" as a parameter, intead of the drive letter.

I already know how to find drive letters, i need only a way to open the "M:" or the "N:" drive
ASKER CERTIFIED SOLUTION
Avatar of jgv
jgv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fcp
fcp

ASKER

YEAH!

I really don't like URL as answer, so i put here the code

Public Declare Function mciSendString Lib "winmm.dll" _
     Alias "mciSendStringA" _
    (ByVal lpstrCommand As String, _
     ByVal lpstrReturnString As String, _
     ByVal uReturnLength As Long, _
     ByVal hwndCallback As Long) As Long

Public Function openCD(ByVal dRv As String) As Long
    Dim Alias As String
    Dim retval As Long
    Alias = "Drive" & dRv
    retval = -1           'we need to set retval to anything other then 0
    retval = mciSendString("open " & dRv & ": type cdaudio alias " & Alias & " wait", vbNullString, 0&, 0&)
    retval = mciSendString("set " & Alias & " door open", vbNullString, 0&, 0&)
    openCD = retval
End Function

Public Function closeCD(ByVal dRv As String) As Long
    Dim Alias As String
    Dim retval As Long
    Alias = "Drive" & dRv
    retval = -1           'we need to set retval to anything other then 0
    retval = mciSendString("set " & Alias & " door closed", vbNullString, 0&, 0&)
    retval = mciSendString("close " & Alias, vbNullString, 0&, 0&)
    closeCD = retval
End Function

THANKS!!!
No problem :)

The reason that I use URL's (in this case anyways) is to give credit where credit is due. The guy who submited that code may have spent alot of time figuring it out and I like to acknowledge them where possible.

Anyways, I'm glad the sample helped you you and thanks for the points and the A grade!
Avatar of fcp

ASKER

You're right :)

The code was submitted at the site by Joe B.