Solved

Open and close the "M;" CDROM drive

Posted on 2002-04-11
4
191 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
You're right :)

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now