Visual Basic 6 Code Request

Discussion in 'Windows Desktop Systems' started by prinsipe, Aug 17, 2004.

  1. prinsipe

    prinsipe Not Too eXPerienced

    Messages:
    208
    I would like to request for VB6 code for the 2 seperate programs that i would like to make:

    first - a program that ejects the CD Tray

    second - a program that loads the CD Tray


    Please take note that there will be no command buttons to click when the .exe file is created, once the exe file is double clicked it automatically executes its purpose.

    thanks for any extended help.....
     
  2. sboulema

    sboulema Moderator

    Messages:
    2,846
    Location:
    Amstelveen, The Netherlands
    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 Form_Load()
    
    Call mciSendString("Set CDAudio Door Open Wait", 0&, 0&, 0&)
    Unload Me
    
    End Sub
    for closing change the Open to Closed.
     
  3. XPos

    XPos OSNN Addict

    Messages:
    88
    Location:
    Kansas
    It took me awhile to get this one... it will compile into one exe but does both open and close the cd tray. Sorry I didn't read the request, you wanted two programs. Oh well.

    Code:
    'vb 6
    Option Explicit
    Dim mssg As String * 255
    
    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 Form_Activate()
       Form1.Visible = False
    End Sub
    
    Private Sub Form_Load()
       'open connection to cdaudio device
       Call mciSendString("open cdaudio alias cd1", 0, 0, 0)
       
       'check the status of the cdaudio divice
       Call mciSendString("status cd1 mode", mssg, 255, 0)
       
       'if the door is open, close it other wise open it
       If Left(mssg, 4) = "open" Then
          Call mciSendString("set cd1 door closed wait", 0, 0, 0)
       Else
          Call mciSendString("set cd1 door open wait", 0, 0, 0)
       End If
       
       'close the connection to the cdaudio device
       Call mciSendString("close cdaudio alias cd1", 0, 0, 0)
       
       Unload Me
    End Sub
    
    
     
  4. prinsipe

    prinsipe Not Too eXPerienced

    Messages:
    208
    Thanks a lot for the help and for replying quickly.