by Barry L. Camp (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (2 Votes)
Empties the Recycle Bin, regardless of what drive/folder assigned to.
Inputs
None.
Assumes
No form required. (Sample uses a standard module instead of a form).
Code Returns
None.
Side Effects
Empties the Recycle Bin. If workstation has more than one drive, *all* Recycled folders (e.g. C:\Recycled) on *all* drives are emptied.
API DeclarationsSHEmptyRecycleBin (Shell32)
' ShellTrash Demo
' by Barry L. Camp ([email protected])
Option Explicit ' The Author's preference.
Const SHERB_NOCONFIRMATION = &H1& ' No dialog confirming the deletion of the objects will be displayed.
Const SHERB_NOPROGRESSUI = &H2& ' No dialog indicating the progress will be displayed.
Const SHERB_NOSOUND = &H4& ' No sound will be played when the operation is complete.
Private Declare Function SHEmptyRecycleBin Lib "shell32" Alias "SHEmptyRecycleBinA" _
(ByVal hWnd As Long, ByVal lpBuffer As String, ByVal dwFlags As Long) As Long
Sub Main()
Dim rc As Long
Dim nFlags As Long
' Suppresses all UI elements, for "quiet" operation.
nFlags = SHERB_NOCONFIRMATION Or SHERB_NOPROGRESSUI Or SHERB_NOSOUND
rc = SHEmptyRecycleBin(0&, vbNullString, nFlags)
End Sub