RecycleBin




Option Explicit

Private Type SHQUERYRBINFO
cbSize As Long ' bytes in this structure
i64Size As Currency ' 64-bit integer with size of items in the Recycle
' Bin

i64NumItems As Currency ' 64-bit integer with number of items in the
' Recycle Bin

End Type

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

' Return number of items in the Recycle Bin for the

' specified drive, or all drives if the argument is

' a null string

'

' If you pass a second argument, it is filled with the

' total size of the items in the Recycle Bin for that drive


Function RecycleBinItems(ByVal RootPath As String, _
Optional NumBytes As Currency) As Long
Dim qInfo As SHQUERYRBINFO

' add a colon and backslash, if missing

If Len(RootPath) > 0 And Mid$(RootPath, 2, 2) <> ":\" Then
RootPath = Left$(RootPath, 1) & ":\"
End If
qInfo.cbSize = Len(qInfo)
Debug.Print SHQueryRecycleBin(RootPath, qInfo)
' scale up the result

RecycleBinItems = qInfo.i64NumItems * 10000
' return the size in the second argument

NumBytes = qInfo.i64Size * 10000
End Function












( recyclebin.html )- by Paolo Puglisi - Modifica del 17/12/2023