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

  • Home
  • SEARCH
  • 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 9216593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:27:04+00:00 2026-06-18T02:27:04+00:00

I am trying to determine if a file is on a local drive. I

  • 0

I am trying to determine if a file is on a local drive. I found GetDriveType() WINAPI which retrieves the drive type. However reading the description of the return values it seems, and thats how I understand it, that it retrieves a flash drive as FIXED which is not what I want.

Its working fine on local drives:

bool IsDriveRemovableOrRemote(CString driveRoot)
{
    UINT driveType = GetDriveType(driveRoot);
    return (DRIVE_REMOVABLE == driveType || DRIVE_CDROM == driveType || DRIVE_NO_ROOT_DIR == driveType || DRIVE_REMOTE == driveType);
}

I don’t have a flash/external drive to test ATM but I would like if someone can tell me if my interpretation is correct? and if so, what better alternative should I use?

Please bear in mind that I only have the path of the file.

  • 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-06-18T02:27:06+00:00Added an answer on June 18, 2026 at 2:27 am

    You should read the doco more closely. While a Flash drive is considered a fixed device, there’s a note in that linked page:

    To determine whether a drive is a USB-type drive, call SetupDiGetDeviceRegistryProperty and specify the SPDRP_REMOVAL_POLICY property.

    The process seems a little messy if all you start with is the path but you can start reading the doco here. It looks like you may need to enumerate the devices until you find one matching your drive.

    To avoid doing this to all your requests, I would do a two-stage check. If your current method says it’s not fixed, treat it as non-local.

    If it says it is fixed, then you can enumerate the devices using my suggested method to be certain.

    Alternatively, you can enumerate all fixed non-USB drives the first time you need to, and then just cache the information. I’m pretty certain that the list of these drives won’t change while the system is running – drives that get added and deleted are, by definition, removable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to determine a file's mime type. I've tried a few methods,
I'm trying to determine the exact absolute path of the local file from only
I am trying to determine where to place a script file in a location
I'm trying to use NSFileManager to determine if an item is a file or
I'd like to determine from a batch file on Windows if a local SVN
I am trying to determine if MY xsl:fo generated PDF file will exceed one
I'm trying to determine a file based on specific parameters. First, I am recursively
I'm trying to determine how many classes are declared in a .java file, using
I am trying to determine what the best project type would be for a
Does ClickOnce only look at the application manifest file to determine which dll files

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.