I've got some old code of mine that I'm going back to and updating a little bit. On one part of it I need to check if there are any items in the recycle bin or not.
This is the code I was using to accomplish this:
vbcode Code:
Private Declare Function SHQueryRecycleBin Lib "shell32.dll" Alias "SHQueryRecycleBinA" (ByVal pszRootPath As String, ByRef pSHQueryRBInfo As SHQUERYRBINFO) As Long Private Structure ULARGE_INTEGER Dim LowPart As Integer Dim HighPart As Integer End Structure Private Structure SHQUERYRBINFO Dim cbSize As Integer Dim i64Size As ULARGE_INTEGER Dim i64NumItems As ULARGE_INTEGER End Structure Public Function IsRecycleBinEmpty() As Boolean Dim SHQBI As SHQUERYRBINFO SHQBI.cbSize = Marshal.SizeOf(SHQBI) SHQueryRecycleBin("", SHQBI) If (SHQBI.i64Size.LowPart <> LastRecycleBinSize) Then MsgBox(SHQBI.i64Size.HighPart.ToString + " - " + SHQBI.i64Size.LowPart.ToString + " - " + SHQBI.i64NumItems.LowPart.ToString + " - " + SHQBI.i64NumItems.HighPart.ToString) LastRecycleBinSize = SHQBI.i64Size.LowPart End If End If (SHQBI.i64NumItems.LowPart) Then IsRecycleBinEmpty = False Else IsRecycleBinEmpty = True End If End Function
The msgbox and end is just in there for debugging purposes. This always returns all 0s, even when I know that there is something in the recycle bin.
Anyone have any ideas on what I'm doing wrong here?
Thanks!




Reply With Quote