VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Empties the recycle Bin.

by Bird (7 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Thu 26th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Empties the recycle Bin.

API Declarations


Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOSOUND = &H4
Private Type ULARGE_INTEGER
LowPart As Long
HighPart As Long
End Type
Private Type SHQUERYRBINFO
cbSize As Long
i64Size As ULARGE_INTEGER
i64NumItems As ULARGE_INTEGER
End Type
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
Private Declare Function SHQueryRecycleBin Lib "shell32.dll" Alias "SHQueryRecycleBinA" (ByVal pszRootPath As String, pSHQueryRBInfo As SHQUERYRBINFO) As Long


Rate Empties the recycle Bin.



    Dim RBinInfo As SHQUERYRBINFO, Msg As VbMsgBoxResult
    RBinInfo.cbSize = Len(RBinInfo)
    SHQueryRecycleBin vbNullString, RBinInfo
    If (RBinInfo.i64Size.LowPart And &H80000000) = &H80000000 Or RBinInfo.i64Size.HighPart > 0 Then
        Msg = MsgBox("Your Recycle Bin consumes over 2 GB right now!" + vbCrLf + "Do you want to empty it?", vbYesNo + vbQuestion)
    Else
        Msg = MsgBox("Your Recycle Bin consumes" + Str$((RBinInfo.i64Size.LowPart) / 102400) + " MB right now." + vbCrLf + "Do you want to empty it?", vbYesNo + vbQuestion)
    End If
    If Msg = vbYes Then
        SHEmptyRecycleBin Me.hwnd, vbNullString, 0
        SHUpdateRecycleBinIcon
    End If
    End
End Sub

Download this snippet    Add to My Saved Code

Empties the recycle Bin. Comments

No comments have been posted about Empties the recycle Bin.. Why not be the first to post a comment about Empties the recycle Bin..

Post your comment

Subject:
Message:
0/1000 characters