|
-
Jul 4th, 2001, 02:41 PM
#1
Thread Starter
Addicted Member
Restoring recycle bin files from VB
Simple question that I cant figure out --
How to restore ALL recycle bin items from VB code.
Thanks all.
BaLLZaCH
[email protected]
VB5 and VB6
-
Jul 4th, 2001, 02:45 PM
#2
PowerPoster
You can only do the following with the recycle bin...
- Empty it
- Query it (see how much space it consumes)
- Update the icon (e.g. if you deleted everything in it, you'd need to update the icon to show the bin empty)
-
Jul 4th, 2001, 03:52 PM
#3
Thread Starter
Addicted Member
Sweet bud, I didnt know that ...
Can you instruct me on how to empty the bin with vb code ?
Thanks bro.
-
Jul 4th, 2001, 04:18 PM
#4
PowerPoster
Sure thing bro...paste this into the declarations section of a form
VB Code:
Const SHERB_NOCONFIRMATION = &H1
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
Private Sub Form_Load()
Dim RBinInfo As SHQUERYRBINFO
Dim 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 gigabytes right now!" + vbCrLf + "Do you want to empty it?", vbYesNo + vbQuestion)
Else
Msg = MsgBox("Your Recycle Bin consumes" + Str$(RBinInfo.i64Size.LowPart) + " bytes 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 Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|