示例#1
0
        static void Main(string[] args)
        {
            VirtualStorageType storageType = new VirtualStorageType();

            storageType.DeviceId = VirtualStorageDeviceTypes.Vhdx;
            storageType.VendorId = VirtualStorageType.VendorIdMicrosoft;

            VirtualDiskSafeHandle diskHandle = new VirtualDiskSafeHandle();

            string filename = @"C:\temp\test.vhdx";

            OpenVirtualDiskParameters readParameters = new OpenVirtualDiskParameters();

            readParameters.Version  = OpenVirtualDiskVersions.Version2;
            readParameters.Version2 = new OpenVirtualDiskParametersVersion2()
            {
                GetInfoOnly    = false,
                ReadOnly       = false,
                ResiliencyGuid = Guid.Empty,
            };

            uint result = VirtualDiskApi.OpenVirtualDisk(storageType,
                                                         filename,
                                                         VirtualDiskAccessMasks.None,
                                                         OpenVirtualDiskFlags.None,
                                                         readParameters,
                                                         diskHandle);

            RawSecurityDescriptor       descriptor = new RawSecurityDescriptor("O:BAG:BAD:(A;;GA;;;WD)");
            AttachVirtualDiskParameters parameters = new AttachVirtualDiskParameters();

            parameters.Version = AttachVirtualDiskVersions.Version1;

            result = VirtualDiskApi.AttachVirtualDisk(diskHandle, descriptor, AttachVirtualDiskFlags.PermanentLifetime, 0, parameters, null);



            diskHandle.Close();
            diskHandle = null;
        }
示例#2
0
 public static extern Int32 OpenVirtualDisk(ref VIRTUAL_STORAGE_TYPE VirtualStorageType, String Path, VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask, OPEN_VIRTUAL_DISK_FLAG Flags, ref OPEN_VIRTUAL_DISK_PARAMETERS Parameters, ref VirtualDiskSafeHandle Handle);
示例#3
0
 public static extern Int32 GetVirtualDiskPhysicalPath(VirtualDiskSafeHandle VirtualDiskHandle, ref Int32 DiskPathSizeInBytes, StringBuilder DiskPath);
示例#4
0
 public static extern Int32 GetVirtualDiskOperationProgress(VirtualDiskSafeHandle VirtualDiskHandle, ref NativeOverlapped Overlapped, ref VIRTUAL_DISK_PROGRESS Progress);
示例#5
0
 public static extern Int32 GetVirtualDiskInformation(VirtualDiskSafeHandle VirtualDiskHandle, ref Int32 VirtualDiskInfoSize, ref GET_VIRTUAL_DISK_INFO VirtualDiskInfo, ref Int32 SizeUsed);
示例#6
0
 public static extern Int32 DetachVirtualDisk(VirtualDiskSafeHandle VirtualDiskHandle, DETACH_VIRTUAL_DISK_FLAG Flags, Int32 ProviderSpecificFlags);
示例#7
0
 public static extern Int32 CreateVirtualDisk(ref VIRTUAL_STORAGE_TYPE VirtualStorageType, String Path, VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask, IntPtr SecurityDescriptor, CREATE_VIRTUAL_DISK_FLAG Flags, Int32 ProviderSpecificFlags, ref CREATE_VIRTUAL_DISK_PARAMETERS Parameters, ref NativeOverlapped Overlapped, ref VirtualDiskSafeHandle Handle);
示例#8
0
 public static extern Int32 AttachVirtualDisk(VirtualDiskSafeHandle VirtualDiskHandle, IntPtr SecurityDescriptor, ATTACH_VIRTUAL_DISK_FLAG Flags, Int32 ProviderSpecificFlags, ref ATTACH_VIRTUAL_DISK_PARAMETERS Parameters, IntPtr Overlapped);
示例#9
0
 public static extern Int32 OpenVirtualDisk(ref VIRTUAL_STORAGE_TYPE VirtualStorageType,
                                            string Path,
                                            VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask,
                                            OPEN_VIRTUAL_DISK_FLAG Flags,
                                            ref OPEN_VIRTUAL_DISK_PARAMETERS Parameters,
                                            ref VirtualDiskSafeHandle Handle);
示例#10
0
 public static extern Int32 SetVirtualDiskInformation(VirtualDiskSafeHandle VirtualDiskHandle, ref SET_VIRTUAL_DISK_INFO VirtualDiskInfo);
 private VirtualHardDisk2(string filename, VirtualDiskSafeHandle handle)
     : base(filename, handle)
 {
 }
示例#12
0
 public static extern Int32 MergeVirtualDisk(VirtualDiskSafeHandle VirtualDiskHandle, MERGE_VIRTUAL_DISK_FLAG Flags, ref MERGE_VIRTUAL_DISK_PARAMETERS Parameters, IntPtr Overlapped);
示例#13
0
 public static extern Int32 GetStorageDependencyInformation(VirtualDiskSafeHandle ObjectHandle, GET_STORAGE_DEPENDENCY_FLAG Flags, Int32 StorageDependencyInfoSize, ref STORAGE_DEPENDENCY_INFO StorageDependencyInfo, ref Int32 SizeUsed);
示例#14
0
 public static extern Int32 ExpandVirtualDisk(VirtualDiskSafeHandle VirtualDiskHandle, EXPAND_VIRTUAL_DISK_FLAG Flags, ref EXPAND_VIRTUAL_DISK_PARAMETERS Parameters, IntPtr Overlapped);
示例#15
0
 public static extern Int32 CompactVirtualDisk(VirtualDiskSafeHandle VirtualDiskHandle, COMPACT_VIRTUAL_DISK_FLAG Flags, ref COMPACT_VIRTUAL_DISK_PARAMETERS Parameters, IntPtr Overlapped);
 protected VirtualHardDiskBase(string filename, VirtualDiskSafeHandle handle)
     : base(filename, handle)
 {
 }