ヘッダー

表紙 > VB.NET サンプル >

VB.NET 2002, VB.NET 2003, VB2005

CDトレイを開閉する

1.CDトレイを開く例

VB.NET2002対応 VB.NET2003対応 VB2005対応

Private Declare Ansi Function MciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpszCommand As String, ByRef lpszReturnString As String, ByVal cchReturn As Integer, ByVal hwndCallback As Integer) As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    MciSendString("Set CDAudio Door Open Wait", Nothing, 0, 0)

End Sub

 

2.CDトレイを閉じる例

VB.NET2002対応 VB.NET2003対応 VB2005対応

Private Declare Ansi Function MciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpszCommand As String, ByRef lpszReturnString As String, ByVal cchReturn As Integer, ByVal hwndCallback As Integer) As Integer

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    MciSendString("Set cdaudio door closed wait", Nothing, 0, 0)

End Sub

 


VB6対応 VB6でも同じ手法でCDトレイを開閉することができます。