|
-
Aug 13th, 2002, 09:45 AM
#1
Thread Starter
New Member
Opening Cd drive
Does anyone know how to Open the CD drive of the computer in VB?
-
Aug 13th, 2002, 01:38 PM
#2
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
-
Aug 13th, 2002, 11:32 PM
#3
Fanatic Member
add a multimedia control to ur program
multimedia1.command = "eject"
-
Aug 14th, 2002, 01:19 AM
#4
Lively Member
cool code you got there hack...can you explain how does the code work...?
-
Aug 14th, 2002, 07:57 AM
#5
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.
Parameters:
· 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|