Opening and Closing CD Tray from VB.NET Application

Initiotech
Posted by Initiotech under VB.NET category on | Views : 3902
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
[code]
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
[/code]

To Close the CD Tray use
[code]
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
[/code]
Hope this Helps.
Regards
Hefin Dsouza

Comments or Responses

Login to post response