FSCTL_DISMOUNT_VOLUME IOCTL (winioctl.h)
Dismounts a volume regardless of whether or not the volume is currently in use. For more information, see the Remarks section.
To perform this operation, call the DeviceIoControl function with the following parameters.
BOOL DeviceIoControl( (HANDLE) hDevice, // handle to a volume (DWORD) FSCTL_DISMOUNT_VOLUME, // dwIoControlCodeNULL, // lpInBuffer0, // nInBufferSizeNULL, // lpOutBuffer0, // nOutBufferSize(LPDWORD) lpBytesReturned, // number of bytes returned (LPOVERLAPPED) lpOverlapped // OVERLAPPED structure );
The FSCTL_DISMOUNT_VOLUME control code will attempt to dismount a volume regardless of whether or not any other processes are using the volume, which can have unpredictable results for those processes if they do not hold a lock on the volume. For information about locking a volume, see FSCTL_LOCK_VOLUME.
The hDevice handle passed to DeviceIoControl must be a handle to a volume, opened for direct access. To retrieve a volume handle, call CreateFile with the lpFileName parameter set to a string of the following form:
where X is a hard-drive partition letter, floppy disk drive, or CD-ROM drive. The application must also specify the FILE_SHARE_READ and FILE_SHARE_WRITE flags in the dwShareMode parameter of CreateFile.
If the specified volume is a system volume or contains a page file, the operation fails.
If the specified volume is locked by another process, the operation fails. To prevent another process from locking the volume, lock it as soon as you open it.
A dismounted volume has the following properties:
- There are no open files.
- The operating system does detect the volume.
Dismounting a volume is useful when a volume needs to disappear for a while. For example, an application that changes a volume file system from the FAT file system to the NTFS file system might use the following procedure.
To change a volume file system
- Open a volume.
- Lock the volume.
- Format the volume.
- Dismount the volume.
- Unlock the volume.
- Close the volume handle.
In Windows 8 and Windows Server 2012, this code is supported by the following technologies.
|Server Message Block (SMB) 3.0 protocol||No|
|SMB 3.0 Transparent Failover (TFO)||No|
|SMB 3.0 with Scale-out File Shares (SO)||No|
|Cluster Shared Volume File System (CsvFS)||See comment|
On CsvFs the node where dismount is issued will see a normal dismount sequence. On all other nodes FS will invalidate all the opened files.
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|
|Header||winioctl.h (include Windows.h)|