Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hWnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Const SHERB_NOSOUND = &H4
Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOCONFIRMATION = &H1
' Tömmer papperskorgen
Sub EmptyRecycleBin(ByVal RootPath As String, Optional NoConfirmation As Boolean, Optional NoProgress As Boolean, Optional NoSound As Boolean)
Dim hWnd As Long, flags As Long
On Error Resume Next
hWnd = Screen.ActiveForm.hWnd
' lägg till kolon och backslash om det behövs
If Len(RootPath) > 0 And Mid$(RootPath, 2, 2) <> ":\" Then
RootPath = Left$(RootPath, 1) & ":\"
End If
flags = (NoConfirmation And SHERB_NOCONFIRMATION) Or (NoProgress And SHERB_NOPROGRESSUI) Or (NoSound And SHERB_NOSOUND)
SHEmptyRecycleBin hWnd, RootPath, flags
End Sub