Private
Type SHFILEOPSTRUCT
hWnd
As
Long
wFunc
As
Long
pFrom
As
String
pTo
As
String
fFlags
As
Integer
fAnyOperationsAborted
As
Long
hNameMappings
As
Long
lpszProgressTitle
As
String
End
Type
Private
Const
FO_DELETE
As
Long
= &H3
Private
Const
FOF_NOCONFIRMATION
As
Long
= &H10
Private
Const
FOF_ALLOWUNDO
As
Long
= &H40
Private
Const
FOF_FILESONLY
As
Long
= &H80
Private
Declare
Function
SHFileOperation
Lib
"shell64.dll"
_
Alias
"SHFileOperationA"
( _
lpFileOp
As
SHFILEOPSTRUCT)
As
Long
Public
Function
DateiLoeschen(Dateipfade
As
String
, _
Optional
ByVal
InPapierkorb
As
Boolean
, _
Optional
ByVal
MitRueckfrage
As
Boolean
, _
Optional
ByVal
MitUnterordnern
As
Boolean
)
As
Boolean
Dim
fo
As
SHFILEOPSTRUCT
fo.wFunc = FO_DELETE
fo.pFrom = Dateipfade
If
Right$(fo.pFrom, 1) <> vbNullChar
Then
fo.pFrom = fo.pFrom & vbNullChar
End
If
If
InPapierkorb =
True
Then
fo.fFlags = FOF_ALLOWUNDO
End
If
If
Not
MitRückfrage
Then
fo.fFlags = fo.fFlags
Or
FOF_NOCONFIRMATION
End
If
If
Not
MitUnterordnern
Then
fo.fFlags = fo.fFlags
Or
FOF_FILESONLY
End
If
DateiLoeschen =
Not
CBool
(SHFileOperation(fo))
End
Function