CodeItBetter Programming Another VB Programming Blog

How to Open & Close CD Rom

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'System & API - How to Open & Close CD Rom
Option Explicit
 
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
 
Sub ControlCdRom(ByVal bAction As Boolean)
    Dim lReturnValue As Long
    If bAction Then
        'open the CDROM
        Call mciSendString("set CDAudio door open", lReturnValue, 127, 0)
    Else
        'Close the CDROM
        Call mciSendString("set CDAudio door closed", lReturnValue, 127, 0)
    End If
End Sub
 
Private Sub cmdCdRomOpen_Click()
    ControlCdRom True
End Sub
 
Private Sub cmdCdRomClose_Click()
    ControlCdRom False
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.