Minggu, 24 April 2011

Program Visual Basic 6.0 ( Mendeteksi Suara Di Dalam PC, Menghapus File Di Dalam Recylce Bin dan Program Mendeteksi Type Drive)


PROGRAM MENDETEKSI SUARA DI DALAM PC ANDA
Private Sub Form_Load()
Dim I As Integer
I = waveOutGetNumDevs()
If  I > 0 Then
MsgBox "Sistem Komputer Kamu Saat Ini Senang Memutar Lagu."
Else
MsgBox "Sistem Komputer Kamu Saat Ini Tidak Memutar Lagu."
End If
End Sub


PROGRAM MENGHAPUS FILE DI DALAM RECYLCLE BIN
Tambahkan Barisan Coding Di bawah Kedalam Modul dengan cara pilih Project – Add Modul.
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Public Const F0_DELETE = &H3
Public Const F0F_ALLOWUNDO = &H40
Public Const F0F_CREATEPROGRESSDLG As Long = &H0

Tuliskan Coding Dibawah ini ke dalam form :
Private Sub Form_Load()
Dim MyBool As Boolean
Mengganti 'c:\MyDir\MyFile.exe' Dengan nama Yang ingin Anda Hapus.
DelToRecycBin ("c:\MyDir\MyFile.exe")
End Sub

Public Function DelToRecycBin(FileName As String)
Dim FileOperation As SHFILEOPSTRUCT
Dim lReturn As Long
On Error GoTo DelToRecycBin_Err
With FileOperation
.wFunc = F0_DELETE
.pFrom = FileName
.fFlags = F0F_ALLOWUNDO + F0F_CREATEPROGRESSDLG
End With
lReturn = SHFileOperation(FileOperation)
Exit Function
DelToRecycBin_Err:
MsgBox Err.Description
End Function

PROGRAM UNTUK MENDETEKSI TYPE DRIVE
'Tambahkan modul untuk proyek Anda (Dalam menu pilih Project -> Add Module, Kemudian klik Open)
'Tambahkan 1 CommandButton (bernama Command1) dan 1 DriveListBox (bernama Drive1) untuk membentuk Anda.
'Pilih di DriveListBox drive yang ingin Anda untuk mendeteksi, dan tekan tombol.
'Masukkan kode untuk modul ini:
Declare Function GetDriveType Lib "kernel32" Alias ​​"GetDriveTypeA" _
(ByVal NDrive As String) As Long
Declare Function GetLogicalDriveStrings Lib "kernel32" Alias ​​"GetLogicalDriveStringsA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

‘masukkan coding di bawah ini ke dalam form :

Private Sub Command1_Click()
DriveType& = GetDriveType(Drive1.Drive)
Select Case DriveType
Case 1, 3: MsgBox "Hard Disk"
Case 2: MsgBox "Floppy Drive"
Case 4: MsgBox "Remote"
Case 5: MsgBox "CD Rom"
Case 6: MsgBox "RamDisk"
End Select
End Sub

0 komentar:

Posting Komentar