Results 1 to 4 of 4

Thread: empty recycle bin

  1. #1
    j2k
    Guest

    empty recycle bin

    hi

    how can i use vb to empty the recycle bin?

    ta

  2. #2
    Lively Member Ali G's Avatar
    Join Date
    Nov 2001
    Location
    Staines
    Posts
    120
    wiv dis wicked code, aye
    VB Code:
    1. Const SHERB_NOCONFIRMATION = &H1
    2. Const SHERB_NOPROGRESSUI = &H2
    3. Const SHERB_NOSOUND = &H4
    4. Private Type ULARGE_INTEGER
    5.   LowPart As Long
    6.   HighPart As Long
    7. End Type
    8. Private Type SHQUERYRBINFO
    9.   cbSize As Long
    10.   i64Size As ULARGE_INTEGER
    11.   i64NumItems As ULARGE_INTEGER
    12. End Type
    13. Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
    14. Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Long
    15. Private Declare Function SHQueryRecycleBin Lib "shell32.dll" Alias "SHQueryRecycleBinA" (ByVal pszRootPath As String, pSHQueryRBInfo As SHQUERYRBINFO) As Long
    16. Private Sub Form_Load()
    17.     Dim RBinInfo As SHQUERYRBINFO, Msg As VbMsgBoxResult
    18.     RBinInfo.cbSize = Len(RBinInfo)
    19.     SHQueryRecycleBin vbNullString, RBinInfo
    20.     If (RBinInfo.i64Size.LowPart And &H80000000) = &H80000000 Or RBinInfo.i64Size.HighPart > 0 Then
    21.         Msg = MsgBox("Your Recycle Bin consumes over 2 gigabytes right now!" + vbCrLf + "Do you want to empty it?", vbYesNo + vbQuestion)
    22.     Else
    23.         Msg = MsgBox("Your Recycle Bin consumes" + Str$(RBinInfo.i64Size.LowPart) + " bytes right now." + vbCrLf + "Do you want to empty it?", vbYesNo + vbQuestion)
    24.     End If
    25.     If Msg = vbYes Then
    26.         SHEmptyRecycleBin Me.hwnd, vbNullString, 0
    27.         SHUpdateRecycleBinIcon
    28.     End If
    29. End Sub

  3. #3
    DaoK
    Guest
    Here is the solution : This Good mvps

  4. #4
    j2k
    Guest
    Many thanks Ali G and DaoK.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width