Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 107,708 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 1,097 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!




Open CD tray using VB.NET

For those that need to add the capability to open the CD tray.

Submitted By: jayman9
Actions:
Rating:
Views: 6,019

Language: VB.NET

Last Modified: January 24, 2008
Instructions: Declare the function and Long variable at the class level. Then use the code where needed to open or close the CD tray.

Snippet


  1. 'private field:
  2. Private setTrayStatus As Long
  3. 'API
  4. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
  5.  (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
  6.   ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
  7.  
  8.  
  9. 'use this code to open the tray:
  10. setTrayStatus = mciSendString("Set CDAudio Door Open", Nothing, 0, 0)
  11.  
  12. 'use this code to close the tray:
  13. setTrayStatus = mciSendString("Set CDAudio Door Closed", Nothing, 0, 0)
  14.  

Copy & Paste


Comments


makram1 2008-07-07 14:54:10

Very good program


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month