Reply
Old August 17th, 2004 Top | #1
 
prinsipe's Avatar
Not Too eXPerienced
Joined: June 2002
Posts: 208
Reputation: 30
Power: 120

Default Visual Basic 6 Code Request

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.....



Every new beginning comes from some other beginnings end...
prinsipe is offline   Reply With Quote
Old August 17th, 2004 Top | #2
 
sboulema's Avatar
OSNN Veteran Addict
Joined: June 2002
Location: Amstelveen, The Netherlands
Posts: 2,846
Reputation: 120
Power: 147

Default

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.
sboulema is offline   Reply With Quote
Old August 18th, 2004 Top | #3
 
XPos's Avatar
OSNN Addict
Joined: August 2002
Location: Kansas
Posts: 88
Reputation: 20
Power: 116

Default

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
XPos is offline   Reply With Quote
Old August 18th, 2004 Top | #4
 
prinsipe's Avatar
Not Too eXPerienced
Joined: June 2002
Posts: 208
Reputation: 30
Power: 120

Default

Thanks a lot for the help and for replying quickly.



Every new beginning comes from some other beginnings end...
prinsipe is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with visual basic 6 saithe Web Design & Coding 1 December 28th, 2005 7:20am
Visual Basic 6 – Drawing Code Help indyjones Web Design & Coding 3 February 19th, 2005 11:46am
Visual Basic Code NLM Web Design & Coding 4 April 18th, 2003 3:47am
Visual Basic JJH35 Web Design & Coding 2 January 31st, 2003 3:41pm
Visual Basic 6.0 rickang Web Design & Coding 1 March 21st, 2002 2:22am