By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,991 Members | 1,887 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

Opening and Closing CD TRAY

Ali Rizwan
100+
P: 927
Hi all,

Here is a simple used to Open and Close CD TRAY.
Comment it PLEASE!


Expand|Select|Wrap|Line Numbers
  1. 'add this lines of code in the declaration section of a standard module.
  2.  '---------------
  3. Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
  4. (ByVal lpszCommand As String, ByVal lpszReturnString As String, _
  5. ByVal cchReturnLength As Long, ByVal hwndCallback As Long) As Long
  6. '--------------
  7.  
  8. 'Now in the module also declare this
  9. '-----------------------------------
  10.  Sub opencd()
  11.      Call mciSendString("set CDAudio door open", 0, 0, 0)
  12.     End Sub
  13.  
  14. Sub closecd()
  15.    Call mciSendString("set CDAudio door closed", 0, 0, 0)
  16.     End Sub
  17. '-----------------------------------
  18. 'Now add two command buttons to the form ( its obvious what i have taken below)
  19. '-----------------------------------
  20. Private Sub Command1_Click()
  21. Call Module1.opencd
  22. End Sub
  23.  
  24. Private Sub Command2_Click()
  25. Call Module1.closecd
  26. End Sub
  27. '----------------------------------
Regards
>> ALI <<
Feb 25 '08 #1
Share this Article
Share on Google+
2 Comments


VladicaJ
P: 15
If your want here it is. COMMONT: good code. I use in some of my programs
Mar 22 '08 #2

P: 18
Very useful and very good
Mar 29 '08 #3