# Re: 删除整个资料夹

Posted by 小刘 on January 30, 1998 at 21:33:57:

In Reply to: 如何不使用deltree而删除整个资料夹(也就是不使用Shell) posted by jony on January 30, 1998 at 11:44:34:

在模组中宣告
Public Const FO_DELETE = &H3
Public Const FOF_NOCONFIRMATION = &H10
Public Const FOF_ALLOWUNDO = &H40

Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Declare Function SHFileOperation Lib "shell32.dll" Alias
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

在CommandButton中……
Private Sub Command1_Click()
Dim SHFileOp As SHFILEOPSTRUCT
SHFileOp.wFunc = FO_DELETE
SHFileOp.pFrom = "C:\Temp\*.*" + Chr(0)
SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION
Call SHFileOperation(SHFileOp)
End Sub

Follow Ups: