Quote:
Originally Posted by hitman797
...get the number of Files in the Recycle Bin and their total size?
|
@hitman797,
ok, i'll add a new function to retrieve RecycleBin info in a future 'FMXInno' update.
currently, there are no new features or bug fixes to push an update.
so, feel free to use your own library until the next update, especially if you need it right now.
Delphi DLL:
Code:
library AMyDll;
{$R *.res}
const
C_M_BYTES = 1024 * 1024;
type
DWORDLONG = UInt64;
DWORD = FixedUInt;
LPCWSTR = PWideChar;
LPSHQUERYRBINFO = ^SHQUERYRBINFO;
SHQUERYRBINFO = packed record
cbSize : DWORD; // Size of struct SHQUERYRBINFO.
i64Size : DWORDLONG; // Files size in Bytes.
i64NumItems : DWORDLONG; // Files Count.
end;
function SHQueryRecycleBinW(pszRootPath: LPCWSTR; pSHQueryRBInfo: LPSHQUERYRBINFO): HResult; stdcall;
external 'shell32.dll' name 'SHQueryRecycleBinW';
function AGetRecycleBinInfo(ARootPath: WideString; var TotalSizeMB: extended;
var FileCount: Integer): Boolean; stdcall;
var
RBInfo: SHQUERYRBINFO; // Structure to store RecycleBin info
RBRoot: LPCWSTR; // Root path for the RecycleBin query
begin
try
// RBRoot <> nil --> Retrieve RecycleBin info from ARootPath.
// RBRoot = nil --> Retrieve RecycleBin info from All Drives.
if Length(ARootPath) = 0 then RBRoot := nil else RBRoot := LPCWSTR(ARootPath);
RBInfo.cbSize := SizeOf(RBInfo); // Set the size of the structure
if SHQueryRecycleBinW(RBRoot, @RBInfo) = S_OK then
begin
TotalSizeMB := RBInfo.i64Size / C_M_BYTES;
FileCount := RBInfo.i64NumItems;
Result := True;
end else
Result := False;
except
Result := False;
end;
end;
exports
AGetRecycleBinInfo;
begin
end.
InnoSetup:
Code:
function AGetRecycleBinInfo(ARootPath: WideString; var TotalSizeMB: Extended; var FileCount: Integer): Boolean;
external 'AGetRecycleBinInfo@files:AMyDll.dll stdcall';
procedure TestBtnClick(Sender: TObject);
var
TotalSizeMB: Extended;
FileCount: Integer;
begin
if AGetRecycleBinInfo('', TotalSizeMB, FileCount) then
begin
Memo.Lines.Add(format('RecycleBin Files Size: < %0.2n GB >', [TotalSizeMB / 1024]));
Memo.Lines.Add(format('RecycleBin Files Count: < %d >', [FileCount]));
end else
Memo.Lines.Add('AGetRecycleBinInfo Error!')
end;
.