Opening and Closing CD Tray from VB.NET Application

Posted by Initiotech under VB.NET category on | Views : 4226
To Open or Close CD Tray's you need to define an API in your Application.
The API Defination is as folows
Declare Function s Lib "winmm.dll" Alias "mciSendStringA" (ByVal mess As String, ByVal retVal As String, ByVal s As Integer, ByVal so As Integer) As Integer

To Open The CD Tray use
Dim exits As Boolean = False
Public Function Open() As Integer
Dim ret As String
ret = New String(CChar(" "), 255)
Open = s("Set CDAudio Door Open Wait", ret, 0&, 0&)
End Function

To Close the CD Tray use
Public Function Closes() As Integer
Dim strReturn As String
strReturn = New String(CChar(" "), 255)
Closes = s("Set CDAudio Door Closed Wait", strReturn, 0&, 0&)
End Function
Hope this Helps.
Hefin Dsouza

Comments or Responses

Login to post response