JCL Help:NtfsMountDeviceAsDrive

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Mounts a device as a drive.


Pascal

 function NtfsMountDeviceAsDrive(const Device: WideString; Drive: Char): Boolean;


Parameters

Parameters Description
const Device: WideString The device to mount. This is a string of the form DeviceMyDevice where MyDevice is replaced with the appropriate device name. For example the first CD-Rom drive would be DeviceCdRom0 and the first partition on the harddrive would be DeviceHarddiskVolume1.
Drive: Char The drive letter to mount the device on. Note that if the drive already exists the previously mounted device is not automatically unmounted first. You must explicitly unmount it or the call will fail.


Return Value

If the function succeeds it returns True, otherwise it returns False. Failure is usually due to the specified device already being mounted or the device name being incorrect. You can call GetLastError but this will usually simply return the error "parameter is incorrect".


Description

NtfsMountDeviceAsDrive mounts the specified device as the specified drive. That is, you can use this function to mount, for example, the CD-Rom drive as drive K. If the mounting succeeds you can then access the CD-Rom by specifying K. Note that a particular device can only be mounted once. If the specified device is already mounted to a drive, you must first delete that mount point using the DeleteVolumeMountPoint API function. Also, keep in mind that mounting a device can have side effects. For example mounting a volume (hard disk partition or CD-Rom) which has an autorun file, will trigger execution of that autorun file (assuming the autorun feature is enabled).


See Also

NtfsIsFolderMountPoint NtfsMountVolume


About

Unit

JclNTFS


Donator

Marcel van Brakel


Notes

Internally this function has to temporarily create a symbolic link for the specified device. This link is deleted as soon as possible. Although very unlikely, it is possible that deleting this link will fail. If so, the function raises an EJclNtfsError exception and exits without mounting the device. If this happens you should try to delete the symbolic link at a later time and retry. See the implementation of this function for how to achieve this.


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page