Monday 2 January 2012

How to open and close the CD tray

hi again, now im going to teach you how to open and close a CD tray, there are some problems in it though but if you create an .exe (build it) and run it works fine.
so first you have to declare the function
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
after that you would want the script to open or close the CD tray, i think the best sub to put it in would be when a button is pressed.
'to open the CD drive
 mciSendString("Set CDAudio Door Open Wait", 0&, 0&, 0&)

'to close the CD drive
  mciSendString("Set CDAudio Door Closed Wait", 0&, 0&, 0&)

this is simply saying open/close the CD drive

hope it helps (with what ever you would use this for)

Download this project

No comments:

Post a Comment