Empty Recyle Bin problem
Posted on 2002-07-25
I use this code to empty the recycle bin and it works in Windows 2000, XP, and 98, but in 98 there is a problem.
After the recycle bin gets emptied, the recycle bin icon on all the drives gets replaced by the folder "Recycled".
(not the desktop icon, just the recycle bin icon on the root drives, d:, e:, etc) BUT, if I run the app again right after emptying, the icons return.
I would like to have this fixed so that the recycle bin icons get refreshed after each time the recycle bin is emptied. Also, I'm very much a beginner at this and I don't know if there is anything wrong with this code.
What I was trying to achieve was a command that would empty the recycle bin on all drives, silently, without confirmation, sound, etc. but I don't know if I did it right, even though it does seem to work, aside from the 98 problem.
This is how i have it now
Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
Const SHERB_NOCONFIRMATION = &H1
Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOSOUND = &H4
Dim retval As Long ' return value
retval = SHEmptyRecycleBin(Form1.hwnd, "", SHERB_NOCONFIRMATION)