468,556 Members | 2,367 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Share your developer knowledge by writing an article on Bytes.

Opening and Closing CD TRAY

Ali Rizwan
927 512MB
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
2 3529
If your want here it is. COMMONT: good code. I use in some of my programs
Mar 22 '08 #2
Very useful and very good
Mar 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by MJEASSOC | last post: by
8 posts views Thread by Mickey Swanson | last post: by
5 posts views Thread by Matthew | last post: by
7 posts views Thread by Martien van Wanrooij | last post: by
2 posts views Thread by =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.