Re: What am i doing wrong?
Probably declared it wrong...
Code:
Option Explicit
' add Microsoft Multimedia Control component
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpCommandString As String, ByVal lpReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Form_Load()
OpenCDDoor
CloseCDDoor
End Sub
Public Sub OpenCDDoor()
Dim retval As Long
retval = mciSendString("set CDAudio door open", "", 0, 0)
End Sub
Public Sub CloseCDDoor()
Dim retval As Long
retval = mciSendString("set CDAudio door closed", "", 0, 0)
End Sub
EDIT: Command is a reserved word, I think. I don't know what you are passing as command, either
Re: What am i doing wrong?
OK, firstly, my default CD ROM / DVD ROM drive is not D:\, it is F:\.
I always have to do this :
Code:
Private 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
Dim sDriveLetter As String
Dim sAlias As String
Private Sub Command3_Click()
sDriveLetter = "F"
sAlias = "CD" & sDriveLetter
mciSendString "open " & sDriveLetter & ": type cdaudio alias " & sAlias & " wait", returnstring, 0&, 0&
mciSendString "set " & sAlias & " door open wait", returnstring, 0&, 0&
mciSendString "close " & sAlias, returnstring, 0&, 0&
End Sub
Private Sub Command4_Click()
sDriveLetter = "F"
sAlias = "CD" & sDriveLetter
mciSendString "open " & sDriveLetter & ": type cdaudio alias " & sAlias & " wait", returnstring, 0&, 0&
mciSendString "set " & sAlias & " door closed wait", returnstring, 0&, 0&
mciSendString "close " & sAlias, returnstring, 0&, 0&
End Sub
My advice is, substitute sDriveLetter = "F" with sDriveLetter = "D" or whatever your default CD / DVD ROM drive is.
Works like a charm