CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    20

    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

  2. #2
    Join Date
    May 2002
    Posts
    1,435

    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

  3. #3
    Join Date
    Aug 2009
    Posts
    20

    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
  •  





Click Here to Expand Forum to Full Width

Featured