Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Open and close the "M;" CDROM drive

Posted on 2002-04-11
4
197 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:fcp
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
jgv earned 100 total points
ID: 6935638
There is a sample at Planet Source Code:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=30201&lngWId=1

Worked with my DVD & CDR drive.
0
 

Author Comment

by:fcp
ID: 6937853
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!!!
0
 
LVL 12

Expert Comment

by:jgv
ID: 6938282
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!
0
 

Author Comment

by:fcp
ID: 6938603
You're right :)

The code was submitted at the site by Joe B.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Paint/Redraw window while dragging 16 82
MS Date Picker 64 bit 32 bit issue 12 59
Help me. 3 60
vbModal 12 57
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question