Solved

List Recycle Bin Items

Posted on 2006-10-24
18
599 Views
Last Modified: 2012-06-27
hi,

i want to list Recycle bin items like http://www.codeproject.com/shell/recyclebin.asp  in VB6.
0
Comment
Question by:cdemir
  • 5
  • 5
  • 4
  • +1
18 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17800927
Hi,

FYI:

"SHFileOperation: Add Recycle Bin Functionality"
[ http://vbnet.mvps.org/index.html?code/shell/recyclebin.htm ]

BFN,

fp.
0
 
LVL 3

Author Comment

by:cdemir
ID: 17800960
hi,

please check the link  http://www.codeproject.com/shell/recyclebin.asp  and read the question carefully.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17800979
Please don't be so patronising.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 3

Author Comment

by:cdemir
ID: 17800993
it's not about patronising. i can google it (also i've googled it) like you. i think, you've missed that point.
0
 
LVL 15

Expert Comment

by:Ryan_R
ID: 17800996
http://vbnet.mvps.org/index.html?code/shell/recyclebin.htm
http://www.devx.com/vb2themax/Tip/18331
http://www.devx.com/vb2themax/Tip/18980

Don't know how to do something in VB6. Apart from EE, google is your best friend.  Just type "VB6 what you want to know", ie   "VB6 Recycle Bin"  or "VB6 System Tray" etc.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17801017
Actually I went straight to the vbnet.mvps.org site without using Google.

Just like I went straight to msdn.microsoft.com & found this for you:

"How the Recycle Bin Stores Files"
[ http://support.microsoft.com/kb/136517 ]


So, open the file "C:\RECYCLED\INFO2" & read the contents into a VB6 listbox (array, dictionary object, or whatever).

BFN,

fp.


0
 
LVL 15

Expert Comment

by:Ryan_R
ID: 17801625
fanpages, what OS are you running? Sure, older version of Windows used C:\Recycled but in XP (at least on this PC) there is no such folder...
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17802169
Hi,

I'm using Windows XP Professional (2002) SP2.

Go into a DOS Prompt (cmd.exe), and navigate to the root folder of a drive monitored by the Recycle Bin function (cd \).

Then type:

dir recycled

(or)

attrib recycled

It's still there! :)

BFN,

fp.

0
 
LVL 15

Expert Comment

by:Ryan_R
ID: 17807557
can't get a command prompt here, but i'll try whenh i get home tonight. (I was suprised to see that it didn't show up the first time, even if I did a Start>Run and typed C:\Recycled  and windows said the folder didn't exist (hidden files showing). I suppose the only thing I didn't do was show the Op Sys files as well.
0
 
LVL 27

Expert Comment

by:Ark
ID: 17808290
Private Sub Command1_Click()
   Dim oShell As Object
   Dim oRecycler As Object
   Set oShell = CreateObject("Shell.Application")
   Set oRecycler = oShell.NameSpace(10)
   For i = 0 To 5
       Debug.Print oRecycler.GetDetailsOf(oRecycler, i),
   Next i
   Debug.Print
   EnumFolders oRecycler
   Set oRecycler = Nothing
   Set oShell = Nothing
End Sub

Private Sub EnumFolders(fld As Object)
   Dim oShell As Object, fldItem As Object
   Dim i As Long
   Set oShell = CreateObject("Shell.Application")
   For Each fldItem In fld.Items
       If fldItem.IsFolder Then
          Call EnumFolders(fldItem)
       End If
       For i = 0 To 5
           Debug.Print fld.GetDetailsOf(fldItem, i),
       Next i
       Debug.Print
   Next
   Set fldItem = Nothing
   Set fld = Nothing
   Set oShell = Nothing
End Sub

0
 
LVL 15

Expert Comment

by:Ryan_R
ID: 17809351
fanpages:  I tried it on that same computer and the result was as expected:

Microsoft Windows XP [Version 5.1.2600]

C:\>cd recycled
The system cannot find the path specified.

C:\>
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17809887
:)

Thanks for your code, Ark.
0
 
LVL 3

Author Comment

by:cdemir
ID: 17809932
hi Ark,

this code works under win98, too?
0
 
LVL 27

Expert Comment

by:Ark
ID: 17816177
Hi
This code implements same technique as from your link (http://www.codeproject.com/shell/recyclebin.asp). The only difference - C++ code use direct binding to IShellFolder interface, while VB code use build in OLE automation. C++ is more flexible and a bit faster, while VB - more easy and compact.
So, requirements are same - IE5 and above, no difference which OS to use.

I'm too lazy to mimic C++ interface, but it's not difficult to fill ListView with folder items/details. The only problem will be with implementing system imagelist for file icons, but there are a lot of samples on how to do this.
0
 
LVL 27

Expert Comment

by:Ark
ID: 17816237
PS. Just now search MSDN and found:
   IShellFolder2 Interface
.............
   Minimum DLL Version shell32.dll version 5.0 or later
.............
   Minimum operating systems Windows 2000, Windows Millennium Edition

But I DID use it via shell automation with w98SE, IE5.5
Unfortunatelly, can not check it now - I use WinXP
0
 
LVL 15

Expert Comment

by:Ryan_R
ID: 17817130
A good tool for developers is to use Virtual PC 2004 (or similar software like VM Ware)
The program is free and it lets you install more than one PC on the one computer. It's a bit like Remote Desktop software (except the remote PC is actually a file stored on your HDD). I have Virtual PC's for 98, 2000, and XP to test my VB apps. Why do i have a XP VPC I hear you ask if I already run XP SP2 as my host OS? Main reason is that when you install VB or another programming tool you get al these extra dll and ocx files that you can add to your projects. Then you make this great app and you want to show to your friends on their PC and it doesn't work becuase all these files are missing from the guy's Windows\System32 folder. So I test it on the XP machine first (although if it works in Win98 chances are it'll work in XP too.)
And if you want to make a setup file for you app you can either use the one built into VB6 which is OK but a much better one is called  Setup2Go  <--  google it (it's free)
0
 
LVL 3

Author Comment

by:cdemir
ID: 17890033
hi Ark,

any idea about restoring these files to original place?
0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 17894533
Add ListView and command button on form

Private Sub FillRecycleLV()
   Dim oShell As Object
   Dim oRecycler As Object
   Dim i As Long
   Set oShell = CreateObject("Shell.Application")
   Set oRecycler = oShell.NameSpace(10)
   With ListView1
       .ListItems.Clear
       .ColumnHeaders.Clear
       For i = 0 To 5
           .ColumnHeaders.Add , , oRecycler.GetDetailsOf(oRecycler, i)
       Next i
   End With
   EnumFolders oRecycler
   Set oRecycler = Nothing
   Set oShell = Nothing
End Sub

Private Sub EnumFolders(fld As Object)
   Dim oShell As Object, fldItem As Object
   Dim i As Long
   Set oShell = CreateObject("Shell.Application")
   For Each fldItem In fld.Items
       If fldItem.IsFolder Then
          Call EnumFolders(fldItem)
       End If
       With ListView1.ListItems.Add(, , fld.GetDetailsOf(fldItem, 0))
          Set .Tag = fldItem
          For i = 1 To 5
              .SubItems(i) = fld.GetDetailsOf(fldItem, i)
          Next i
       End With
   Next
   Set fldItem = Nothing
   Set fld = Nothing
   Set oShell = Nothing
End Sub

Private Sub Command1_Click()
   Dim li As Object
   Set li = ListView1.SelectedItem
   li.Tag.InvokeVerb
   FillRecycleLV
End Sub

Private Sub Form_Load()
   Caption = "Recycle bin"
   Command1.Caption = "Restore"
   ListView1.View = lvwReport
   ListView1.FullRowSelect = True
   FillRecycleLV
End Sub

Private Sub Form_Resize()
   If WindowState = vbMinimized Then Exit Sub
   ListView1.Move 0, 0, ScaleWidth, ScaleHeight - Command1.Height - 120
   Command1.Move ScaleWidth - Command1.Width - 60, ScaleHeight - Command1.Height - 60
End Sub
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
A macro to Count the number of rows across all worksheets 3 97
clicking a shape in a frame array vb6 3 45
Child Form in front 4 47
Export Data to Different .csv Files 26 105
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question