Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6681417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:35:16+00:00 2026-05-26T04:35:16+00:00

I have an application which uses the FOF_ALLOWUNDO with SHFileOperation in order to move

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:35:17+00:00Added an answer on May 26, 2026 at 4:35 am

    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:

    [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
        private struct SHQUERYRBINFO
        {
            /// DWORD->unsigned int
            public uint cbSize;
    
            /// __int64
            public long i64Size;
    
            /// __int64
            public long i64NumItems;
        }
    
        /// Return Type: HRESULT->LONG->int
        ///pszRootPath: LPCTSTR->LPCWSTR->WCHAR*
        ///pSHQueryRBInfo: LPSHQUERYRBINFO->_SHQUERYRBINFO*
        [System.Runtime.InteropServices.DllImportAttribute("shell32.dll", EntryPoint = "SHQueryRecycleBinW")]
        private static extern int SHQueryRecycleBinW([System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPTStr)] string pszRootPath, ref SHQUERYRBINFO pSHQueryRBInfo);
    
        public bool DriveHasRecycleBin(string Drive)
        {
            SHQUERYRBINFO Info = new SHQUERYRBINFO();
            Info.cbSize = 20; //sizeof(SHQUERYRBINFO)
            return SHQueryRecycleBinW(Drive, ref Info) == 0;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a desktop application which uses flat files (some xml and small pictures)
I have an application which uses two sharedpreferences (so two xml files) to operate.
I have an application which uses gtkmm. The client's machine does not have this
I have an application which uses some Tabs. The functionality of these tabs is
I have an application which uses some external library for analytics. Problem is that
I have application which uses Sherlock ActionBar package. The application uses platform-specific behavior for
I have an application which uses the microsoft kinect device. The thing is that
I have an application which uses code that produces various types of objects and
I have an application which uses JSPs and Servlets and deployed on IBM-WASCE 2.1.
I have a web application which uses the globalization values being passed from sql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.