• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Visual Basic 6 Code Request

prinsipe

Not Too eXPerienced
#1
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
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.
 

XPos

OSNN Addict
#3
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
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,240
Members
89,016
Latest member
timpage