I have an application which uses the FOF_ALLOWUNDO with SHFileOperation in order to move files to the recycle bin.
Some removable drives do not have a recycle bin. In this case SHFileOperation deletes the files directly. I want to give a warning to the user that the files are going to be deleted directly.
In order to do this I need to know if the drive has a recycle bin.
I found a function called SHQueryRecycleBin when I looked at the functions exported by shell32.dll.
If the drive specified in pszRootPath has a recycle bin the function returns 0 otherwise it returns -2147467259.
I'm going to use this function via PInvoke.
I used the P/Invoke Interop Assistant to create the PInvoke code.
Here is the code of my function DriveHasRecycleBin: