Determine if Drive is a local drive

Posted on 2004-11-02
Last Modified: 2013-12-03
I have a service application that can not use a mapped drive for working directory.
I want to add code to my setup program that will detect if the user has selected a path that is not on a local drive.

How can I detect if a drive is local or if it's a mapped drive?
Question by:Axter
    LVL 48

    Expert Comment

    LVL 14

    Accepted Solution

    You need to use the GetDriveType API, which tells you whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.

    UINT GetDriveType(LPCTSTR lpRootPathName);

    lpRootPathName: Pointer to a null-terminated string that specifies the root directory of the disk to return information about. A trailing backslash is required. If this parameter is NULL, the function uses the root of the current directory.
    Return Values: The return value specifies the type of drive. It can be one of the following values.

    DRIVE_UNKNOWN: The drive type cannot be determined.
    DRIVE_NO_ROOT_DIR: The root path is invalid. For example, no volume is mounted at the path.
    DRIVE_REMOVABLE: The disk can be removed from the drive.
    DRIVE_FIXED: The disk cannot be removed from the drive.
    DRIVE_REMOTE: The drive is a remote (network) drive.
    DRIVE_CDROM: The drive is a CD-ROM drive.
    DRIVE_RAMDISK: The drive is a RAM disk.

    The API is documented at
    LVL 30

    Author Comment


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
    In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now