SHEmptyRecycleBin Function

Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long

Platforms

Description & Usage

SHEmptyRecycleBin deletes the contents of the Recycle Bin, displaying dialog boxes as desired. The function can empty the Recycle Bin of a particular drive, or it can empty all Recycle Bins as a whole.

Return Value

If an error occured, the function returns a non-zero error code. If successful, the function returns 0.

Visual Basic-Specific Issues

None.

Parameters

hwnd
A handle to the window calling the function. This window will be the owner of any dialog boxes the function uses.
pszRootPath
A path belonging to the drive to empty the Recycle Bin of (this doesn't have to be the root path). To empty all Recycle Bins as a whole, set this to an empty string.
dwFlags
A combination of zero or more of the following flags specifying additional options:
SHERB_NOCONFIRMATION
Do not display a confirmation prompt for the user.
SHERB_NOPROGRESSUI
Do not display the dialog box displaying the progress of emptying the Recycle Bin.
SHERB_NOSOUND
Do not play the Empty Recycle Bin sound after the contents of the Recycle Bin are deleted.

Constant Definitions

Const SHERB_NOCONFIRMATION = &H1
Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOSOUND = &H4

Example

' Delete the contents in the system's Recycle Bin, without
' showing the progress dialog.  If an error occurs, be safe and
' make sure the proper Recyle Bin icon is used.
Dim retval As Long  ' return value

' Delete the contents of the system's Recycle Bin, if the user OKs it.
retval = SHEmptyRecycleBin(Form1.hWnd, "", SHERB_NOPROGRESSUI)

' If an error occured, be overly save and refresh the Recycle Bin
' icon.  This probably isn't necessary, however.
If retval <> 0 Then  ' error
  retval = SHUpdateRecycleBinIcon()
End If

Related Functions

SHQueryRecycleBin, SHUpdateRecycleBinIcon

Category

Shell

Back to the index.


Last Modified: September 1, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information

Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/s/shemptyrecyclebin.html