DelphiFAQ Home Search:
General :: Programming :: Visual Basic
General Visual Basic related information.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Eject CD Tray code for VB

Question:

I need like to have an eject CD tray option in the Menu. Can you show me some Visual Basic code for that?

Answer:

The fairly universal function mciSendString will do this for you.

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
 
 Private Sub cmdOpenCD_Click()
 Dim lRet As Long
     lRet = mciSendString("set CDAudio door open", returnstring, 127, 0)
 End Sub
 
 Private Sub cmdCloseCD_Click()
 Dim lRet As Long
     lRet = mciSendString("set CDAudio door closed", returnstring, 127, 0)
 End Sub
 

Generated 0:02:28 on Nov 25, 2017