Eject cd code

Discussion in 'Web Design & Coding' started by tkole, Jan 5, 2003.

  1. tkole

    tkole Guest

    I have been trying to find a way to eject my cdrom with a single executable file and found this from Kruger in a search:

    Script below:

    ****
    Option Explicit

    Public 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 Command1_Click()

    Call mciSendString("Set CDAudio Door Open Wait", 0&, 0&, 0&)

    End Sub
    '--end block--'

    ****

    I am totally new to prgramming and wonder how I might use this info to create a single executable file?
     
  2. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    It looks like VB code anyway. I suggest you paste it into a new Visual Basic project. I think you might want to change it a bit:

    Code:
    Option Explicit 
    
    Public 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 
    
    Sub Main() 
        Call mciSendString("Set CDAudio Door Open Wait", 0&, 0&, 0&) 
    End Sub
    I think that's the syntax, but I'm not sure. I haven't programmed in VB for years.