GetSpecialFolder / sfRecycleBin appears not to work

delphi package - easy access to shell apis

GetSpecialFolder / sfRecycleBin appears not to work

Postby atocaciu » Thu Jul 29, 2004 8:28 pm

Dear Madshi,

I am evaluating your madCollection, and trying to build a small program for obtaining system summary.

I saw that everyone in this forum praises your package - and I fully agree with them. I intended to do that too, but it is too common :wink: so i'll go straight to the point.

On my machine, madShell's GetSpecialFolder works fine, except for sfRecycleBin, to which it returns something like ::{645FF040-5081-101B-9F08-00AA002F954E}. I've searched through the registry and there are some keys with this name, that contain strings like 'Recycle Bin', but none of them contains any reference to the actual path for the Recycle Bin itself, so it is a dead end.

On the same machine, there are one Windows 98 SE and one Windows XP ~2600. The problem is the same on both of them. Both copies are legal and are correctly installed as far as I know.

How can I correct the problem?

Thank you,
Alan
atocaciu
 
Posts: 3
Joined: Thu Jul 29, 2004 8:04 pm

Postby madshi » Sat Jul 31, 2004 9:55 am

Hi Alan,

the problem is quite simple: madShell tells you the normal file path (like "C:\whatever") whenever one exists. If there's no file path, it returns a GUID path (like "::{...}\::{...}"). If you browse through the naming space with the explorer you'll meet a lot of objects which have no normal file path. E.g. "My Computer" doesn't have a path like "C:\whatever". You could eventually identify "My Computer" by searching for an object with the name "My Computer", but what happens if the object was renamed? So for non-file-system objects madShell uses those GUID paths. Evidently the recycle bin is such a non-file-system object. madShell asks Windows for a file path, but Windows claims there is none. As a result madShell returns the GUID path. Well, but there IS a recycle folder on each drive! Yes, there is. But (for XP at least) Windows combines all those folders from all writable drives to one object, which is the recycle bin object.

Try this: Empty the recycle bin in XP. Then delete one file from harddisk partition "C:" and one file from partition "D:". Now execute the command line "explorer.exe ::{645FF040-5081-101B-9F08-00AA002F954E}". You'll see the recycle bin and you'll see *both* files in it - although the deleted files are stored in two different recycle bin folders. Do you see the problem? Which path is Windows supposed to give you? "C:\Recycled" or "D:\Recycled"?
madshi
Site Admin
 
Posts: 9268
Joined: Sun Mar 21, 2004 5:25 pm

Postby atocaciu » Tue Aug 03, 2004 8:52 am

Hi Madshi,

Thank you for your extensive answer.
I was aware of some parts of the mechanism you described (which by the way was also kind and way beyond strictly your library's domain), and your package gives a reasonable answer to my request from this point of view.

I was only asking how can i get the Recycle Bin(s) path(s) using your library.
Or, alternatively, I can benefit from a method to empty the entire Recycle Bin using your library. Is there any?

Thank you again for your support,
Alan
atocaciu
 
Posts: 3
Joined: Thu Jul 29, 2004 8:04 pm

Postby madshi » Tue Aug 03, 2004 9:35 am

Well, Windows refuses to give us a recycle bin path, and in the registry there's no real path, either - so my components can't give you one.

Emptying the recycle bin is quite easy, though (but doesn't work in the older OSs):

Code: Select all
procedure EmptyRecycleBin;
var SHEmptyRecycleBin : function (window: dword; root: pchar; flags: dword) : integer; stdcall;
begin
  SHEmptyRecycleBin := GetProcAddress(GetModuleHandle(shell32), 'SHEmptyRecycleBinA');
  if @SHEmptyRecycleBin <> nil then
    SHEmptyRecycleBin(0, nil, 7);
end;
madshi
Site Admin
 
Posts: 9268
Joined: Sun Mar 21, 2004 5:25 pm

Postby atocaciu » Wed Aug 04, 2004 8:20 am

Madshi,

Thank you very much for your assistance and for the quick answers.

Have a nice day,
Alan
atocaciu
 
Posts: 3
Joined: Thu Jul 29, 2004 8:04 pm

Postby naldira » Thu May 13, 2010 5:41 am

How to recover deleted data on the recycle bin after emtying it? Can I ask for some assistance on how to recover my data's after empying the recycle bin.
Last edited by naldira on Fri May 21, 2010 6:23 am, edited 1 time in total.
naldira
 
Posts: 1
Joined: Thu May 06, 2010 7:50 am

Postby madshi » Tue May 18, 2010 8:29 am

I don't know how that works.
madshi
Site Admin
 
Posts: 9268
Joined: Sun Mar 21, 2004 5:25 pm


Return to madShell

Who is online

Users browsing this forum: No registered users and 1 guest