CodeItBetter Programming Another VB Programming Blog

How to Empty Recycle Bin

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'System & API - How to Empty Recycle Bin
Option Explicit
 
Const SHERB_NOCONFIRMATION = &H1
Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOSOUND = &H4
Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" _
    (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Long
 
Public Sub EmptyRecycleBin()
    SHEmptyRecycleBin 0&, vbNullString, SHERB_NOCONFIRMATION Or SHERB_NOPROGRESSUI Or SHERB_NOSOUND
    SHUpdateRecycleBinIcon
End Sub
Comments (1) Trackbacks (0)
  1. I wanted a quick way to automate emptying the Trash Bin. Since Vista makes me switch to XL to do any VB programming, I decided to paste the code into Excel. Put a Button on Sheet One and had the Button call the code I pasted. It worked just fine as is.

    Thank you!


Leave a comment


 

No trackbacks yet.