PDA

View Full Version : Vb.net code to eject cd from drive


zerihun_m
Oct 7, 2009, 11:35 PM
Sir

How to open or close cd drive using vb.net code .

Perito
Oct 8, 2009, 06:05 AM
Opening and closing the CD tray in .NET (C# Programming Tutorial) • Geekpedia (http://www.geekpedia.com/tutorial174_Opening-and-closing-the-CD-tray-in-.NET.html)

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

Basically, you declare a function from WinMM.dll (Windows Multi-media library), as shown above, and call it. This will then open the door (if you have only one CD):

mciSendString "Set CDAudio Door Open Wait", 0&, 0&, 0&

This will close the door:

mciSendString "Set CDAudio Door Closed Wait", 0&, 0&, 0&

The article, above, shows how to open a drive if multiple drives are in the system. The code in the article is in C#, but the strings in the "mciSendString" calls are what you need and they don't vary from language to language.

jeya_raman09
Jan 7, 2011, 10:32 PM
videocoferencing code for ASP.net with c#