?
Solved

List Recycle Bin Items

Posted on 2006-10-24
18
Medium Priority
?
610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 28

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 28

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 28

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 28

Accepted Solution

by:
Ark earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

752 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