Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eject CD

Status
Not open for further replies.

TudorSmith

Programmer
Jan 14, 2002
245
GB
Hi,

I have a VB app that runs my MP3's from a CD. When I close the application I would like the CD to eject from the drive automatically as the program ends.

I am using the MediaPlayer control.

Anyone got any code I can use that will eject the CD?

Thanks

birklea birklea ~©¿©~ <><
I know what I know...don't presume that I know what I don't! Smithism!!!
 
Code:
Option Explicit

Private Declare Function MCISendString Lib &quot;winmm.dll&quot; Alias &quot;mciSendStringA&quot; (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Sub OpenCD()
  Dim Ret    As Long
  Dim RetStr As String
  Ret = MCISendString(&quot;set CDAudio door open&quot;, RetStr, 127, 0)
End Sub
Sub CloseCD()
  Dim Ret    As Long
  Dim RetStr As String
  Ret = MCISendString(&quot;set CDAudio door closed&quot;, RetStr, 127, 0)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top