When you delete a file in Windows Explorer or My Computer, the file appears in the Recycle Bin. The file remains in the Recycle Bin until you empty the Recycle Bin or restore the file.
Here's how to programmatically display the Recycle Bin to a user of your Delphi application.
uses
ShlObj, ShellAPI, ... ;Place a TButton named "OpenBinButton" on a form, handle its OnClick event as:
procedure TRecycleBinForm.OpenBinButtonClick(Sender: TObject) ;
var
recycleBinPIDL: PItemIDList;
execInfo: TShellExecuteInfo;
begin
SHGetSpecialFolderLocation(Handle, CSIDL_BITBUCKET, recycleBinPIDL) ;
with execInfo do
begin
cbSize := Sizeof(execInfo) ;
fMask := SEE_MASK_IDLIST;
Wnd := Handle;
lpVerb := nil;
lpFile := nil;
lpParameters := nil;
lpDirectory := nil;
nShow := SW_SHOWNORMAL;
hInstApp:=0;
lpIDList := recycleBinPIDL;
end;
ShellExecuteEx(@execInfo) ;
end;
Note: The code uses the SHGetSpecialFolderLocation Shell API function to get the location of the Recycle Bin, as a special folder (by passing the CSIDL_BITBUCKET value).
ShellExecuteEx is used to open the Recycle Bin's "folder".
Related: Delete files with the ability to UNDO (delete to Recycle Bin), Empty Recycle Bin (from Delphi code, of course).
Delphi tips navigator:
» How to Jump to the Last Item in the TListBox
« Activate a Running Instance when a User Opens an Associated File (By Extension)

