Visual Basic 6 Code Request

prinsipe

Not Too eXPerienced
Joined
21 Jun 2002
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.....
 
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.
 
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 profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back