unit uMain;
interface
uses
Windows, Messages, SysUtils, Forms,
ActiveX,
Buttons, ComObj, ShlObj, Dialogs, StdCtrls, StrUtils, ExtCtrls,
ComCtrls, Controls, Classes;
type
TfrmMain =
class(TForm)
btnShowNumOfTrashFiles: TButton;
procedure btnShowNumOfTrashFilesClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
type
PPIDLItem = ^TPIDLItem;
TPIDLItem =
Record
Dateiname :
String;
IDL : PItemIDList;
end;
function NumTrashFiles : Integer;
var
DeskDirI, RecycleI: IShellFolder;
pReIDL, pNextIDL: PItemIDList;
EnumList: IENUMIDLIST;
IsThere: Cardinal;
StrRet: TStrRet;
parName:
String;
PPIDL:PPIDLItem;
begin
OleCheck(SHGetDesktopFolder(DeskDirI));
OleCheck(SHGetSpecialFolderLocation(Application.Handle, CSIDL_BITBUCKET, pReIDL));
OleCheck(DeskDirI.BindToObject(pReIDL,
nil, IShellFolder, RecycleI));
CoTaskMemFree(pReIDL);
OleCheck(RecycleI.EnumObjects(Application.Handle,
SHCONTF_FOLDERS
or SHCONTF_NONFOLDERS
or SHCONTF_INCLUDEHIDDEN, EnumList));
Result := 0;
while EnumList.Next(1, pNextIDL, IsThere) = S_OK
do Inc(Result, 1);
end;
procedure TfrmMain.btnShowNumOfTrashFilesClick(Sender: TObject);
begin
ShowMessage(IntToStr(NumTrashFiles));
end;
end.