Win32 Windows Volume Program and Code Example 13

 

 

 

Mounted Folders (drives)

 

The NTFS file system supports mounted folders. A mounted folder is an association between a volume and a directory on another volume. When a mounted folder is created, users and applications can access the target volume either by using the path to the mounted folder or by using the volume's drive letter. For example, a user can create a mounted folder to associate drive D: with the C:\Mnt\DDrive folder on drive C. After creating the mounted folder, the user can use the C:\Mnt\DDrive path to access drive D: as if it were a folder on drive C:.

Using mounted folders, you can unify disparate file systems such as the NTFS file system, a 16-bit FAT file system, and an ISO-9660 file system on a CD-ROM drive into one logical file system on a single NTFS volume. Neither users nor applications need information about the target volume on which a specific file is located. All the information they need to locate a specified file is a complete path using a mounted folder on the NTFS volume. Volumes can be rearranged, substituted, or subdivided into many volumes without users or applications needing to change settings.

 

 

 

How to create a mounted drive

 

To mount a volume:

 

  1. Click Start, click Run, and then type compmgmt.msc in the Open box or open the Computer Management snap-in from Administrative Tools (Windows XP Pro SP2).
  2. In the left pane, click Disk Management.
  3. Right-click the partition or volume that you want to mount, and then click Change Drive Letter and Paths.
  4. Click Add.
  5. Click Mount in the following empty NTFS folder (if it is not already selected), and then use one of the following steps:

 

·         Type the path to an empty folder on an NTFS volume, and then click OK.

·         Click Browse, locate the empty NTFS folder, click OK, and then click OK.

·         If you have not yet created an empty folder, click Browse, click New Folder to create an empty folder on an NTFS volume, type a name for the new folder, click OK, and then click OK.

 

  1. Quit the Disk Management snap-in.

 

How to remove a mounted drive

 

To remove a mounted volume:

 

  1. Click Start, click Run, and then type compmgmt.msc in the Open box or open the Computer Management snap-in from other short-cut.
  2. In the left pane, click Disk Management.
  3. Right-click the partition or volume that you want to unmount, and then click Change Drive Letter and Paths.
  4. Click the mounted drive path that you want to remove, and then click Remove.
  5. Click Yes when you are prompted to remove the drive path.
  6. Quit the Disk Management snap-in.

 

When you attempt to mount a volume on a folder on an NTFS volume, you may receive the following error message:

 

The folder you specified is not empty. A volume can be mounted only at an empty folder.

 

This message is displayed when the folder in which you want to mount the volume is not empty. To resolve this issue, create a new empty folder in which to mount the volume, or delete the contents of the folder, and then mount the volume.

When you attempt to mount a volume on a folder on an NTFS volume, you may receive the following error message:

 

The path provided is on a file system that does not support drive paths.

 

This message is displayed if the volume is not formatted with the NTFS file system. To resolve this issue, make sure that the volume in which you want to host the mounted drive is an NTFS volume. The following steps show how to mount a drive to an empty folder. We will mount D: drive to an empty folder, mountdrive.

 

How to mount a drive to an empty folder

 

Firstly we create an empty folder named mountdrive on drive C:.

 

How to mount a drive to an empty folder - creating an empty folder

 

Next, through Computer Management snap-in, we invoke the Change Drive Letter and Paths page while selecting D: drive.

 

How to mount a drive to an empty folder - invoking the CHnage Drive Letter and Paths

 

Next, click the Add button.

 

How to mount a drive to an empty folder - adding a drive to be mounted

 

Select the second radio button, Mount in the following empty NTFS folder. Then click the Browse button to browse the folder that we will mount this drive. In this case it is the mountdrive created previously.

 

How to mount a drive to an empty folder - adding an empty folder to mount a drive

 

 

Click the mountdrive and click OK button.

 

How to mount a drive to an empty folder - selecting the empty drive to be mounted

 

Click OK button to complete the tasks.

 

How to create a mounted drive - selecting the folder to mount the drive

 

The following Figure shows the mounted drive through Windows Explorer.

 

How to create a mounted drive - the mounted drive as seen through Windows explorer

 

The mounted drive properties page is shown below.

 

How to create a mounted drive - the mounted drive property page

 

To remove the mounted drive, invoke the same menu.

 

How to remove a mounted drive - invoking the Change Drive Letter and Paths menu

 

 

Select the mounted drive and click Remove button.

 

How to remove a mounted drive - selecting the mounted drive

 

The folder is back to a normal folder.

 

How to remove a mounted drive - the drive has been mounted as seen in Windows explorer

 

 

  < Windows Volume 12 | Win32 Programming Index | Windows Volume Index | Windows Volume 14 >