Results 1 to 5 of 5

Thread: Opening Cd drive

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    5

    Opening Cd drive

    Does anyone know how to Open the CD drive of the computer in VB?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 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
    2.  
    3. Private Sub cmdOpenDrive_Click()
    4. Dim OpenCDDrive As Long
    5. OpenCDDrive = mciSendString("set CDAudio door open", "", 127, 0)
    6. End Sub
    7.  
    8. Private Sub cmdCloseCD_Click()
    9. Dim CloseCD As Long
    10. CloseCD = mciSendString("set CDAudio door closed", "", 127, 0)
    11. End Sub

  3. #3
    Fanatic Member Mushroom Realm's Avatar
    Join Date
    Mar 2002
    Location
    Murrieta, California
    Posts
    650
    add a multimedia control to ur program

    multimedia1.command = "eject"

  4. #4
    Lively Member
    Join Date
    May 2002
    Location
    Malaysia
    Posts
    103
    cool code you got there hack...can you explain how does the code work...?

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    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
  •  



Click Here to Expand Forum to Full Width