List Recycle Bin Items

hi,

i want to list Recycle bin items like http://www.codeproject.com/shell/recyclebin.asp  in VB6.
LVL 3
cdemirAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ArkConnect With a Mentor Commented:
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
 
[ fanpages ]IT Services ConsultantCommented:
Hi,

FYI:

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

BFN,

fp.
0
 
cdemirAuthor Commented:
hi,

please check the link  http://www.codeproject.com/shell/recyclebin.asp  and read the question carefully.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
[ fanpages ]IT Services ConsultantCommented:
Please don't be so patronising.
0
 
cdemirAuthor Commented:
it's not about patronising. i can google it (also i've googled it) like you. i think, you've missed that point.
0
 
Ryan_RIT Systems AdministratorCommented:
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
 
[ fanpages ]IT Services ConsultantCommented:
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
 
Ryan_RIT Systems AdministratorCommented:
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
 
[ fanpages ]IT Services ConsultantCommented:
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
 
Ryan_RIT Systems AdministratorCommented:
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
 
ArkCommented:
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
 
Ryan_RIT Systems AdministratorCommented:
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
 
[ fanpages ]IT Services ConsultantCommented:
:)

Thanks for your code, Ark.
0
 
cdemirAuthor Commented:
hi Ark,

this code works under win98, too?
0
 
ArkCommented:
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
 
ArkCommented:
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
 
Ryan_RIT Systems AdministratorCommented:
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
 
cdemirAuthor Commented:
hi Ark,

any idea about restoring these files to original place?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.