Finding the Recycle Bin on a local NTFS drive

前端 未结 4 2061
我寻月下人不归
我寻月下人不归 2021-01-03 09:33

I\'m trying to write some simple code that will return the directory for the recycle bin on a local drive. Seems like it would be simple -- should be a thousand answers on

4条回答
  •  伪装坚强ぢ
    2021-01-03 10:08

    A little bit late, but perhaps better late than never...

    After debugging shell32.dll, I have found that for each version of windows the recycle path is hardcoded and, also, depends on the filesystem of that drive. I have tested this on Windows XP, Vista and Windows7:

    Let X: be the drive we want to get the path to the recycle bin and let SID be the SID of the current user, then:

    
        switchif(OsType) {
            case WindowsXP:
            {
                if(PartitionType("X:") == NTFS)
                {
                    printf("Path is: X:\\Recycler\\SID\\");
                }
                else
                {
                    printf("Path is X:\\RECYCLED\\");
                }
            }
    
            case WindowsVista:
            case Windows7:
            {
                if(PartitionType("X:") == NTFS)
                {
                    printf("Path is: X:\\$Recycle.bin\\SID\\");
                }
                else
                {
                    printf("Path is X:\\$RECYCLE.BIN\\");
                }
            }
        }
    
    

    A wiki article presents the same facts: http://en.wikipedia.org/wiki/Recycle_Bin_%28Windows%29

提交回复
热议问题