Solved

List Recycle Bin Items

Posted on 2006-10-24
18
593 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now