- 1 Module, 1 CommandButton
---------------------------------------------------------------------------------
- Pada Module
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
---------------------------------------------------------------------------------
- Pada Form
Private Sub Command1_Click()
Dim MyBool As Boolean
'Ganti nama file di bawah dengan nama file yang ingin Anda hapus.
DelToRecycBin ("c:\My Documents\MyFile.Zip")
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.Number & Err.Description
End Function
Senin, 11 Agustus 2008
Menghapus File ke Recycle Bin
Langganan:
Posting Komentar (Atom)

Tidak ada komentar:
Posting Komentar