SHQueryRecycleBin Function

Declare Function SHQueryRecycleBin Lib "shell32.dll" Alias "SHQueryRecycleBinA" (ByVal pszRootPath As String, pSHQueryRBInfo As SHQUERYRBINFO) As Long

Platforms

Description & Usage

SHQueryRecycleBin retrieves information about how many files (or other items) are currently in the Recycle Bin as well as how much disk space they consume. This function will work with the Recycle Bin specific to a certain drive, as well as work with the Recycle Bin as considered over the entire system.

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

pszRootPath
A path which is on the drive to query the Recycle Bin of. If this string is empty, the function instead queries all Recycle Bins on the system as a whole.
pSHQueryRBInfo
Receives the number of bytes in the Recycle Bin and the number of items in it. The cbSize member of the structure must be initialized before calling the function.

Example

' This code is licensed according to the terms and conditions listed here.

' Display the number of items in the Recycle Bin on the C:
' drive and the size of it.
Dim rbinfo As SHQUERYRBINFO  ' information about the bin
Dim retval As Long  ' return value

' Initialize the size of the structure.
rbinfo.cbSize = Len(rbinfo)
' Query the contents of C:'s Recycle Bin.
retval = SHQueryRecycleBin("C:\", rbinfo)  ' the path doesn't have to be the root path
' Display the number of items in the Recycle Bin, if the value is
' within Visual Basic's numeric display limits.
If (rbinfo.i64NumItems.LowPart And &H80000000) = &H80000000 Or rbinfo.i64NumItems.HighPart > 0 Then
  Debug.Print "Recycle Bin contains more than 2,147,483,647 items."
Else
  Debug.Print "Recycle Bin contains"; rbinfo.i64NumItems.LowPart; "items."
End If
' Likewise display the number of bytes the Recycle Bin is taking up.
If (rbinfo.i64Size.LowPart And &H80000000) = &H80000000 Or rbinfo.i64Size.HighPart > 0 Then
  Debug.Print "Recycle Bin consumes more than 2,147,483,647 bytes."
Else
  Debug.Print "Recycle Bin consumes"; rbinfo.i64Size.LowPart; "bytes."
End If

See Also

SHEmptyRecycleBin

Category

Shell

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: August 31, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/s/shqueryrecyclebin.html