Dalam aplikasi ini yang dibutuhkan adalah :
- 3 Commandbutton, dengan properties name Command1, Command2, Command3
- 1 form, dengan properties name form1
- 1 modul, dengan properties name module1
Masukkan Code Dibawah ini pada module1
Option Explicit Public 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 Public Function OpenCDDoor(ByVal drv As String) As Long Dim Alias As String Dim retval As Long Alias = "Drive" & drv retval = -1 retval = mciSendString("open " & drv & ": type cdaudio alias " & Alias & " wait", vbNullString, 0&, 0&) retval = mciSendString("set " & Alias & " door open", vbNullString, 0&, 0&) OpenCDDoor = retval End Function Public Function CloseCDDoor(ByVal drv As String) As Long Dim Alias As String Dim retval As Long Alias = "Drive" & drv retval = -1 retval = mciSendString("set " & Alias & " door closed", vbNullString, 0&, 0&) retval = mciSendString("close " & Alias, vbNullString, 0&, 0&) CloseCDDoor = retval End Function
Masukkan code di bawah inipada form
Private Sub Command1_Click() OpenCDDoor "G" 'pastikan drive G adalah drive untuk CD/DVD Room, jika bukan G tinggal anda ubah G tersebut menjadi Huruf sesuai dng Drive CD/DVD Room End Sub Private Sub Command2_Click() CloseCDDoor "G" 'pastikan drive G adalah drive untuk CD/DVD Room, jika bukan G tinggal anda ubah G tersebut menjadi Huruf sesuai dng Drive CD/DVD Room End Sub Private Sub Command3_Click() End End Sub
Semoga bermanfaat.
Download Project Open Close CD-Room
No comments:
Post a Comment