Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Mar 29, 2020 12:09 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to empty your RecycleBin
PostPosted: Sun Jun 26, 2011 1:11 pm 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Hello i converted a VB code to Rb for windows. That shows you how you can empty your Recycle Bin an check how many files that are in the Recycle Bin before you empty it. Hope you enjoy :)


Sub EmptyRecycleBin( DriveLetter As String )
'Converted from VB6 to RB
'http://www.vbforums.com/archive/index.php/t-225892.html

Const SHERB_NOCONFIRMATION = &H1
Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOSOUND = &H4

Soft Declare Function SHQueryRecycleBinW Lib "shell32" ( pszRootPath As WString, pSHQueryRBInfo As Ptr ) As Integer
Soft Declare Function SHQueryRecycleBinA Lib "shell32" ( pszRootPath As CString, pSHQueryRBInfo As Ptr ) As Integer
Soft Declare Function SHEmptyRecycleBinA Lib "shell32" ( hwnd As Integer, pszRootPath As CString, dwFlags As Integer) As Integer
Soft Declare Function SHEmptyRecycleBinW Lib "shell32" ( hwnd As Integer, pszRootPath As WString, dwFlags As Integer) As Integer
Soft Declare Function SHUpdateRecycleBinIcon Lib "shell32" () As Integer

Dim f As FolderItem

#if TargetWin32 then
If DriveLetter = "" Then
Else
f = GetTrueFolderItem( DriveLetter )
End

while f.Parent <> nil
f = f.Parent
wend

dim mb as new MemoryBlock( 25 )
mb.Long( 0 ) = mb.Size
dim retval as Int64

if System.IsFunctionAvailable( "SHQueryRecycleBinW", "shell32" ) then
retval = shQueryrecyclebinW( f.AbsolutePath, mb )
elseif System.IsFunctionAvailable( "SHQueryRecycleBinA", "shell32" ) then
retval = shQueryrecyclebinA( f.AbsolutePath, mb )
end if

retval = mb.Int64Value( 12 )

If retval = 0 Then 'error
MsgBox "Could not empty"
Else
Dim d as New MessageDialog
Dim b as MessageDialogButton
d.icon=MessageDialog.GraphicQuestion
d.ActionButton.Caption="Yes"
d.CancelButton.Visible=True
d.AlternateActionButton.Visible=False
d.AlternateActionButton.Caption="No"
d.Message="Your Recycle Bin consumes " + Str( retval ) + " files right now."
d.Explanation="Do you want to empty it? "

Dim nFlags As Integer
dim rc as Boolean
nFlags= SHERB_NOCONFIRMATION

b=d.ShowModal
Select Case b
Case d.ActionButton
If System.IsFunctionAvailable( "SHEmptyRecycleBinW", "shell32" ) then
rc = SHEmptyRecycleBinW( 0, f.AbsolutePath, nFlags ) = 0
elseif System.IsFunctionAvailable( "SHEmptyRecycleBinA", "shell32" ) then
rc = SHEmptyRecycleBinA( 0, f.AbsolutePath, nFlags ) = 0
end if

if rc AND System.IsFunctionAvailable( "SHUpdateRecycleBinIcon", "shell32" ) then
Call SHUpdateRecycleBinIcon
End
Case d.CancelButton
Exit Sub
End select
end
#endif
End Sub


Top
 Profile  
Reply with quote  
 Post subject: Re: How to empty your RecycleBin
PostPosted: Sun Jun 26, 2011 1:16 pm 
Offline

Joined: Fri Sep 30, 2005 10:49 pm
Posts: 504
Could you post the VB code also, so that I can see how it is done?
Thanks.
Lennox


Top
 Profile  
Reply with quote  
 Post subject: Re: How to empty your RecycleBin
PostPosted: Sun Jun 26, 2011 1:16 pm 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
the link is at the top of the code


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group