Home > Windows API > Recycle bin functions!

Recycle bin functions!

To query recycle bin information call ShQueryRecycleBin!

An e.g.

void GetchMeRecycleBinInfo()
   SHQUERYRBINFO RecycleBinInfo = { 0 };
   RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
   VERIFY( SHQueryRecycleBin( _T( "C:" ), NULL ) == S_OK ); // Get recycle bin info

   // Display information
   CString csRecycleBinInfo;
   csRecycleBinInfo.Format( _T( " Recycle bin size: %I64d, Recycle bin item count: %I64d" ), RecycleBinInfo.i64Size, RecycleBinInfo.i64NumItems );
   MessageBox( NULL, csRecycleBinInfo, _T( "Recycle bin" ), MB_OK | MB_ICONINFORMATION );
}// End GetchMeRecycleBinInfo

// To empty a recycle bin call ShEmptyRecycleBin!
if( MessageBox ( NULL, _T( "Empty recycle bin?" ), _T( "Question" ), MB_OK | MB_YESNO ) == IDYES )
   // If second parameter i.e. drive, is empty then recycle bins on all drives
   // will be emptied, last parameter takes some flags, look up MSDN for details,
   // pretty easy ones!
   SHEmptyRecycleBin( NULL, NULL, 0 );
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: