说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

VB如何将文件删除到回收站

HTML文档下载 WORD文档下载 PDF文档下载
VB如何将文件删除到回收站

VB提供的Kill语句将文件直接彻底删除,而不是放到回收站中。
那么,如何将文件删除到回收站中呢?
下面就是答案:

Option Explicit
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
Public Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Const FO_DELETE = &H3
Public Const FOF_ALLOWUNDO = &H40

Public Sub Recycle(ByVal FileName As String)
Dim SHFileOp As SHFILEOPSTRUCT
Dim RetVal As Long
With SHFileOp
.wFunc = FO_DELETE
.pFrom = FileName
.fFlags = FOF_ALLOWUNDO
End With
'Send this poor soul to file hell
RetVal = SHFileOperation(SHFileOp)
End Sub
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘