Bah, what's the API call that ejects/pulls in the CD Rom's drive? I've had it before but I can't remember.
Printable View
Bah, what's the API call that ejects/pulls in the CD Rom's drive? I've had it before but I can't remember.
Code:'Open and close the cd door
Option Explicit
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
'===============================================================
'To open the CD door, use this code:
retvalue = mcisendstring("set CDAudio door open", _
returnstring, 127, 0)
'To close the CD door, use this code:
retvalue = mcisendstring("set CDAudio door closed", _
returnstring, 127, 0)
The code listed above didn't work for me but this code does:
Code:Option Explicit
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
Private Sub CloseCDDoor(ByVal DriveLetter As String)
'This will close the specified cd-rom drive. e.g. Call CloseCDDoor("e")
Dim AliasName As String
AliasName = "Drive" & DriveLetter
mciSendString "open " & DriveLetter & ": Alias " & AliasName _
& " Type CDAudio", 0, 0, 0
mciSendString "Set " & AliasName & " door Closed", 0, 0, 0
End Sub
Private Sub OpenCDDoor(ByVal DriveLetter As String)
'This will open the specified cd-rom drive. e.g. Call OpenCDDoor("e")
Dim AliasName As String
AliasName = "Drive" & DriveLetter
mciSendString "eject " & DriveLetter & ": Alias " & AliasName _
& " Type CDAudio", 0, 0, 0
mciSendString "Set " & AliasName & " door open", 0, 0, 0
End Sub