Kill "C:\Documents and Settings\dengkeyu\Cookies\*.txt"
这样删行吗。我发现 IE的临时文件夹里还有cookies记录。该怎么删掉呢?
在标准工程中添加一个公共对话框和两个按钮即可尝试本例: 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
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