Determine if Drive is a local drive

Posted on 2004-11-02
Medium Priority
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

ID: 12475853
LVL 14

Accepted Solution

RichieHindle earned 2000 total points
ID: 12476066
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/getdrivetype.asp
LVL 30

Author Comment

ID: 12476455

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Loops Section Overview

840 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