|
 |
推荐文章 |
|
|
|
|
|
|
|
|
|
|
| 作者:土人 日期:2005-8-4 11:32:55 |
|
|
在标准工程中添加一个公共对话框和两个按钮即可尝试本例:
Option Explicit
'删除文件的API
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As ToBin) As Long
'清空回收站的API
Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Private Type ToBin
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type
Const FO_DELETE = &H3
Const FOF_ALLOWUNDO = &H40
Const SHERB_NORMAL = &H0
'将文件移至回收站
Private Sub Command1_Click()
Dim Go As ToBin
Dim strFile As String
With CommonDialog1
.Filter = "(*.bak)|*.bak"
.DialogTitle = "删除文件"
.ShowOpen
strFile = .FileName
End With
With Go
.wFunc = FO_DELETE
.pFrom = strFile
.fFlags = FOF_ALLOWUNDO
End With
SHFileOperation Go
End Sub
'清空回收站
Private Sub Command2_Click()
Dim RetVal As Long
RetVal = SHEmptyRecycleBin(0&, vbNullString, SHERB_NORMAL)
End Sub |
|
|
|
|
|
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
|
|
|
|
|
责任编辑: 原点 |
投稿作者: 土人 |
|
|
信息来源: 网络 |
录入时间: 2005-8-4 11:32:55 |
|
|
|
| |
|