Does anyone know how to Open the CD drive of the computer in VB?
Printable View
Does anyone know how to Open the CD drive of the computer in VB?
VB 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 Private Sub cmdOpenDrive_Click() Dim OpenCDDrive As Long OpenCDDrive = mciSendString("set CDAudio door open", "", 127, 0) End Sub Private Sub cmdCloseCD_Click() Dim CloseCD As Long CloseCD = mciSendString("set CDAudio door closed", "", 127, 0) End Sub
add a multimedia control to ur program
multimedia1.command = "eject"
cool code you got there hack...can you explain how does the code work...?
Parameters:Quote:
The mciSendString function sends a command string to an MCI device. The device that the command is sent to is specified in the command string.
· lpszCommand
Address of a null-terminated string that specifies an MCI command string.
In my examples, the command strings are: "set CDAudio door open" and "set CDAudio door closed"
· lpszReturnString
Address of a buffer that receives return information. If no return information is needed, this parameter can be NULL.
In both examples, no information is needed, therefore I leave this parameter NULL
· cchReturn
Size, in characters, of the return buffer specified by the lpszReturnString parameter.
127 is the size of the return buffer. I'm sure I've read why that is, but I can't remember. I just know that it works.
· hwndCallback
Handle of a callback window if the “notify” flag was specified in the command string.
The notify flag was not specified, therefore this parameter is 0.