VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 使删除后的文件到回收站里
发表评论(0)作者:, 平台:, 阅读:12214, 日期:2000-03-12
 


如何将文件删除到回收站



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

如果你想删除文件"A.*",只需调用Recyle "A.*"即可