Solved

Open and close the "M;" CDROM drive

Posted on 2002-04-11
4
196 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now