Adblock breaks this site

Open/Close CD Drive

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

  1. Arkane

    Arkane Guest

    Referrals:
    0
    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.
     
  2. Jazz00006

    Jazz00006 Apprentice
    Visual Basic Programmers

    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0
    Open/Close CD Drive

  3. X Zero

    X Zero Forum Addict

    Joined:
    Jan 21, 2007
    Posts:
    577
    Referrals:
    0
    Sythe Gold:
    0
    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?)
     
  4. Le_Dark_Lord

    Le_Dark_Lord Forum Addict
    Banned

    Joined:
    Dec 6, 2005
    Posts:
    451
    Referrals:
    3
    Sythe Gold:
    0
    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 >


 
 
Adblock breaks this site