Exemplo n.º 1
0
        /// <summary>
        /// Unsurfaces (detaches) a virtual hard disk (VHD) by locating an appropriate VHD provider to accomplish the operation.
        /// </summary>
        public void Detach(
            DETACH_VIRTUAL_DISK_FLAG flags = DETACH_VIRTUAL_DISK_FLAG.DETACH_VIRTUAL_DISK_FLAG_NONE)
        {
            if (!IsAttached)
            {
                return;
            }

            var ret = NativeMethods.DetachVirtualDisk(CheckDisposed(), flags, 0);

            switch (ret)
            {
            case NativeMethods.ERROR_NOT_FOUND:
            // There's nothing to do here.  The device wasn't found, which means there's a
            // really good chance that it wasn't attached to begin with.
            // And, since we were asked to detach it anyway, we can assume that the system
            // is already in the desired state.
            case NativeMethods.ERROR_SUCCESS:
                break;

            default:
                throw new Win32Exception(ret);
            }
        }
Exemplo n.º 2
0
 public static extern int DetachVirtualDisk(IntPtr virtualDiskHandle, DETACH_VIRTUAL_DISK_FLAG flags, Int32 providerSpecificFlags);
Exemplo n.º 3
0
 public static extern Int32 DetachVirtualDisk(VirtualDiskSafeHandle VirtualDiskHandle, DETACH_VIRTUAL_DISK_FLAG Flags, Int32 ProviderSpecificFlags);
Exemplo n.º 4
0
 public static extern uint DetachVirtualDisk(IntPtr Handle, DETACH_VIRTUAL_DISK_FLAG Flag, uint ProviderSpecificFlags);