예제 #1
0
        /// <summary>
        /// Reduces the size of the virtual hard disk (VHD) backing store file. Supports both sync and async modes.
        /// </summary>
        /// <param name="overlapped">If not null, the operation runs in async mode</param>
        /// <param name="flags">Flags for Compact operation</param>
        public void Compact(
            IntPtr overlapped,
            COMPACT_VIRTUAL_DISK_FLAG flags = COMPACT_VIRTUAL_DISK_FLAG.COMPACT_VIRTUAL_DISK_FLAG_NONE)
        {
            var compactParams = new NativeMethods.COMPACT_VIRTUAL_DISK_PARAMETERS();

            compactParams.Version = NativeMethods.COMPACT_VIRTUAL_DISK_VERSION.COMPACT_VIRTUAL_DISK_VERSION_1;
            var ret = NativeMethods.CompactVirtualDisk(CheckDisposed(), flags, ref compactParams, overlapped);

            if ((overlapped == IntPtr.Zero && ret != NativeMethods.ERROR_SUCCESS) ||
                (overlapped != IntPtr.Zero && ret != NativeMethods.ERROR_IO_PENDING))
            {
                throw new Win32Exception(ret);
            }
        }
예제 #2
0
 /// <summary>
 /// Reduces the size of the virtual hard disk (VHD) backing store file.
 /// </summary>
 /// <param name="flags">Flags for Compact operation</param>
 public void Compact(COMPACT_VIRTUAL_DISK_FLAG flags = COMPACT_VIRTUAL_DISK_FLAG.COMPACT_VIRTUAL_DISK_FLAG_NONE) => Compact(IntPtr.Zero, flags);
예제 #3
0
 public static extern int CompactVirtualDisk(IntPtr VirtualDiskHandle, COMPACT_VIRTUAL_DISK_FLAG Flags, ref COMPACT_VIRTUAL_DISK_PARAMETERS Parameters, IntPtr Overlapped);
예제 #4
0
 public static extern Int32 CompactVirtualDisk(VirtualDiskSafeHandle VirtualDiskHandle, COMPACT_VIRTUAL_DISK_FLAG Flags, ref COMPACT_VIRTUAL_DISK_PARAMETERS Parameters, IntPtr Overlapped);
예제 #5
0
 public static extern UInt32 CompactVirtualDisk(
     VirtualDiskSafeHandle VirtualDiskHandle,
     COMPACT_VIRTUAL_DISK_FLAG Flags,
     IntPtr Parameters,  // to make it optional (pass IntPtr.Zero)
     IntPtr Overlapped); // to make it optional (pass IntPtr.Zero)
예제 #6
0
 public static extern UInt32 CompactVirtualDisk(
     VirtualDiskSafeHandle VirtualDiskHandle,
     COMPACT_VIRTUAL_DISK_FLAG Flags,
     ref COMPACT_VIRTUAL_DISK_PARAMETERS Parameters,
     ref OVERLAPPED Overlapped);