Mega Code Archive

 
Categories / Delphi / Files
 

Get the number of files in recycle bin and the size of recycle bin

Title: Get the number of files in recycle bin and the size of recycle bin Question: How to get the number of files in recycle bin and the size of recycle bin Answer: To get the number files in the recycle bin, you have to use the function SHQueryRecycleBin. this function is available in the shell32 module. This function is supported in Win98 or above. The function declarartion is as shown below function SHQueryRecycleBin(pszrtootpath:pchar;QUERYRBINFO:pshqueryrbinfo):integer;stdcall; external 'shell32' name 'SHQueryRecycleBinA'; The SHQUERYBINFO Structure is as follows type SHQUERYRBINFO =packed record cbSize:integer;// size of structure i64Size:int64;// size of recycle bin i64NumItems:int64;// number of items in recycle bin. end; The cbsize must be set before calling the function The first parameter must be the drive of which the recyclebin must be queried. If the drive 'C' then the parameter must be'C:\'; if the parameter is empty then the function queries the recyclebin on all the harddisks as a whole. the second parameter is a pointer to SHQUERYBINFO Structure. The function returns 0 if successful. The function can be called as follows var rbinfo:SHQUERYRBINFO; begin SHQueryRecycleBin('C:\',@rbinfo); end;