priyamtheone
Well-known member
- Joined
- Sep 20, 2007
- Messages
- 96
- Programming Experience
- Beginner
Hi friends,
I hav got two problems while accessing cd drives.
FIRSTLY: I want a code example of how to detect whether the cd drive of my machine is opened or closed.
SECONDLY: I'm trying to open or close the cd drive of my machine. It's working properly if there's only one cd drive. But wut if there r more than one. The code I'm using is accessing the default cd drive only. Below is the code I'm using:
'In the general declarations:
'----------------------------------------
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
pstrReturnString As String, ByVal uReturnLength As Long, ByVal _
wndCallback As Long) As Long
'The procedure that performs the cd drive door open/close operation
'-------------------------------------------------------------------------------------------------
Public Sub OpenOrShutCDDrive(DoorOpen As Boolean)
Dim lRet As Long
If DoorOpen Then
lRet = mciSendString("Set CDAudio Door Open", 0&, 0&, 0&)
Else
lRet = mciSendString("Set CDAudio door closed", 0&, 0&, 0)
End If
'lRet will = 0 upon success, so if you want to make this
'a function, return true if lret = 0, false otherwise
End Sub
'In Button1_click event:
'-----------------------------------
'Parameter for calling the following procedure will be true or false
Call OpenOrShutCDDrive(True)
Now, how can I open/close the cd drive of my choice? Should I have to provide the path name of the drive then how to do it? Plz help.
I hav got two problems while accessing cd drives.
FIRSTLY: I want a code example of how to detect whether the cd drive of my machine is opened or closed.
SECONDLY: I'm trying to open or close the cd drive of my machine. It's working properly if there's only one cd drive. But wut if there r more than one. The code I'm using is accessing the default cd drive only. Below is the code I'm using:
'In the general declarations:
'----------------------------------------
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
pstrReturnString As String, ByVal uReturnLength As Long, ByVal _
wndCallback As Long) As Long
'The procedure that performs the cd drive door open/close operation
'-------------------------------------------------------------------------------------------------
Public Sub OpenOrShutCDDrive(DoorOpen As Boolean)
Dim lRet As Long
If DoorOpen Then
lRet = mciSendString("Set CDAudio Door Open", 0&, 0&, 0&)
Else
lRet = mciSendString("Set CDAudio door closed", 0&, 0&, 0)
End If
'lRet will = 0 upon success, so if you want to make this
'a function, return true if lret = 0, false otherwise
End Sub
'In Button1_click event:
'-----------------------------------
'Parameter for calling the following procedure will be true or false
Call OpenOrShutCDDrive(True)
Now, how can I open/close the cd drive of my choice? Should I have to provide the path name of the drive then how to do it? Plz help.