/// <summary> /// Dismount the drive. /// </summary> /// <returns></returns> /// <remarks></remarks> public bool Detach() { if (!Attached) { return(false); } uint r = VirtDisk.DetachVirtualDisk(_Handle, DETACH_VIRTUAL_DISK_FLAG.DETACH_VIRTUAL_DISK_FLAG_NONE, 0U); return(r == 0L); }
public override bool UnmountCurrentDiskImage() { if (mountedHandle != null) { Win32Error error = VirtDisk.DetachVirtualDisk(mountedHandle, VirtDisk.DETACH_VIRTUAL_DISK_FLAG.DETACH_VIRTUAL_DISK_FLAG_NONE, 0); if (error.Failed) { AutoMounter.Plugin.LogInfo($"WinVirtDisk: Failed to unmount disk from system {mountedHandle.ToString()}, {error.ToString()}"); AutoMounter.API.Dialogs.ShowErrorMessage("Failed to unmount disk from system", "AutoMounter"); } mountedHandle.Close(); mountedHandle = null; } return(true); }