|
-
August 22nd, 2009, 08:05 AM
#1
SHQueryRecycleBin in Debug and Release config
hi, i know that default Debug configuration differs a little bit from Release (optimizations, etc etc), but why code below works fine in Debug and fails in Release
i want to check whatever recyclebin is empty or not:
Code:
SHQUERYRBINFO BinInfo;
if (SHQueryRecycleBin(NULL,&BinInfo)!=S_OK)
//SHQueryRecycleBin failed
if ( BinInfo.i64NumItems == 0 ) // recycle bin is empty
// do something
i have experimented with recyclebin path but without success
-
August 22nd, 2009, 08:24 AM
#2
Re: SHQueryRecycleBin in Debug and Release config
BinInfo needs to be initialized. In both cases, release and debug, its content in your code is undefined. Debug mode generally fills uninitialized memory with default values to aid tracking down problems like this, hence the difference in behavior. It really shouldn't work in debug mode but a possible explanation is that cbSize is initialized with 0xCDCDCDCD which works out to a very large value and Windows is only looking for a minimum size. In release mode all uninitialized memory may be zero which would cause cbSize to be too small. Just a possible explanation though - you can't assume anything about uninitialized memory.
Code:
SHQUERYRBINFO BinInfo;
::ZeroMemory(&BinInfo, sizeof(BinInfo));
BinInfo.cbSize = sizeof(BinInfo);
if (SHQueryRecycleBin(NULL,&BinInfo)!=S_OK)
//SHQueryRecycleBin failed
if ( BinInfo.i64NumItems == 0 ) // recycle bin is empty
// do something
-
August 22nd, 2009, 08:37 AM
#3
Re: SHQueryRecycleBin in Debug and Release config
**** i failed, thank you sir, works fine now
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|