[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Open and close the "M;" CDROM drive

Posted on 2002-04-11
4
Medium Priority
?
208 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 400 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

831 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