Open/Close CD Drive

Discussion in 'Archives' started by Arkane, Jul 12, 2007.

Open/Close CD Drive
  1. Unread #1 - Jul 12, 2007 at 3:40 AM
  2. Arkane
    Referrals:
    0

    Arkane Guest

    Open/Close CD Drive

    This is a really old source to my first Visual Basic program, it opens and closes the CD drive.

    Code:
    Option Base 1
    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()
    '           CD Open/Close  Program
    '                                       -Arkane
    '                                           [email protected]
     
    Dim Now As String
      Dim a(2) As String
      a(1) = "set cdaudio door open"
      a(2) = "set cdaudio door closed"
      total = 1     'Set this to the number of cycles you want it to undergo
       For i = 1 To (total * 2)
      If Int(i / 2) = i / 2 Then
      Now = vbString(a(2), 0)
      Else
      Now = vbString(a(1), 0)
      End If
      Next i
     
    End Sub
    Function vbString(ByVal Command As String, ByVal hWnd As Long) As String
        Dim Buff As String
        Dim dwR As Long
        Buff = Space$(100) ' Create a buffer
        dwR = mciSendString(Command, ByVal Buff, Len(Buff), hWnd)
        vbString = Buff
    End Function
     
    That is just the code to my first program, a more simple way is to use Visual Basic's MMControl. Put one on to a form, add a command button and set these properties:

    Do not change the controls' names.

    Set MMControl1's DeviceType to CDAudio.
    Set MMControl1's EjectEnabled to True

    Code:
    Private Sub Command1_Click()
    MMControl1.Command = "Eject"
    End Sub
    
    Private Sub Form_Load()
    MMControl1.Command = "Open"
    End Sub 
    Feedback is welcomed (as always), suggestions will NOT be taken into consideration since this is old and a un-used program, this obviously cant be used on laptops by the way.
     
  3. Unread #2 - Jul 12, 2007 at 5:47 AM
  4. Jazz00006
    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0

    Jazz00006 Apprentice
    Visual Basic Programmers

    Open/Close CD Drive

  5. Unread #3 - Jul 12, 2007 at 7:46 AM
  6. X Zero
    Joined:
    Jan 21, 2007
    Posts:
    577
    Referrals:
    0
    Sythe Gold:
    0

    X Zero Forum Addict

    Open/Close CD Drive

    oh shit man, u got kained :D Twice lol

    it didn't work for me anyways. (or did i even try?)
     
  7. Unread #4 - Jul 23, 2007 at 12:17 AM
  8. Le_Dark_Lord
    Joined:
    Dec 6, 2005
    Posts:
    451
    Referrals:
    3
    Sythe Gold:
    0

    Le_Dark_Lord Forum Addict
    Banned

    Open/Close CD Drive

    Whats an MMcontrol?

    How do i configure it or whatever...
     
< ~~selling pure mage lvl 86 mage and combat lvl 59!!~~ | Selling Uk Sms Pin >

Users viewing this thread
1 guest


 
 
Adblock breaks this site