Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  Answer this Question    Ask about Visual Basic    Ask about another Subject  
 

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.