Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Oct 2, 1999

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 Long

Const SHERB_NOCONFIRMATION = &H1
Const SHERB_NOPROGRESSUI = &H2
Const 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 sounds

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

    ' 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, flags
End Sub

Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date