Egon
Egon

Reputation: 11

Get memory size and object count of Recycle Bin

I'm using Borland C++Builder 6 Enterprise on Windows 10.

I have the following code to extract the memory size and object count of the Recycle Bin:

...
#include "shellapi.h"
...

void __fastcall TForm6::Button10Click(TObject *Sender)
{
 SHQUERYRBINFO rbinfo;
 AnsiString sSize,
            sCount;

 int rc;

 unsigned __int64   i64Size,
                    i64Cnt;

 rbinfo.cbSize=sizeof(rbinfo);
 rc=SHQueryRecycleBin("C:\\", &rbinfo);
 if (rc!=S_OK)
     Application->MessageBox( "Fehler bei SHQueryRecycleBin", "Fehler", MB_OK | MB_ICONERROR);
     else
     {

     i64Size = rbinfo.i64Size;
     i64Cnt  = rbinfo.i64NumItems;

     sSize =AnsiString(rbinfo.i64Size);
     sCount=AnsiString(rbinfo.i64NumItems);

     Application->MessageBox(sSize.c_str(), "Speicherplatz", MB_OK | MB_ICONINFORMATION);
     Application->MessageBox(sCount.c_str(), "Anzahl Objekte", MB_OK | MB_ICONINFORMATION);
     }
}

The function gets the total wrong values. The memory size is greater than disk space. The object count is 43628621390151600.

What am I doing wrong here?

Hello

  1. I replace int to HRESULT.

  2. The return values from the API function are already wrong.

     rbinfo.i64Size=433791696898
     sSize=         433791696898
     rbinfo.i64NumItems=0
     sCount            =0
    
  3. The tool Secure Eraser shows 206.195 files and 197.121,3 MB in Recycle
    Bin. (picture) The tool CCleaner shows 560 files (objects) and 36.441.834 KB in Recycle
    Bin. (CCleaner.jpg) In Windows Explorer there are also 560 objects in Recycle Bin.

Upvotes: 1

Views: 171

Answers (0)

Related Questions