Opening and closing the CD tray in .NET (C# Programming Tutorial) • Geekpedia 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.