devxlogo

EmptyRecycleBin – Delete all files in the Recycle Bin

EmptyRecycleBin – Delete all files in the Recycle Bin

Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias _    "SHEmptyRecycleBinA" (ByVal hWnd As Long, ByVal pszRootPath As String, _    ByVal dwFlags As Long) As LongConst SHERB_NOCONFIRMATION = &H1Const SHERB_NOPROGRESSUI = &H2Const SHERB_NOSOUND = &H4' Empty all the files in the Recycle Bin.'' If RootPath is a null string, it affects the Recycle Bin ' of all drives. You can optionally turn off confirmation dialogs, ' progress dialog, and soundsSub EmptyRecycleBin(ByVal RootPath As String, Optional NoConfirmation As _    Boolean, Optional NoProgress As Boolean, Optional NoSound As Boolean)    Dim hWnd As Long, flags As Long    ' get the handle of the active window, or zero    On Error Resume Next    hWnd = Screen.ActiveForm.hWnd    ' add a colon and backslash, if missing    If Len(RootPath) > 0 And Mid$(RootPath, 2, 2) <> ":" Then        RootPath = Left$(RootPath, 1) & ":"    End If    ' build the flags argument    flags = (NoConfirmation And SHERB_NOCONFIRMATION) Or (NoProgress And _        SHERB_NOPROGRESSUI) Or (NoSound And SHERB_NOSOUND)    SHEmptyRecycleBin hWnd, RootPath, flagsEnd Sub

See also  Monetize TikTok For Your Business
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist