unit Unit2;
interface
uses Sysutils, Windows;
{$ALIGN ON}
{$MINENUMSIZE 4}
const
VirtDisk_dll = '
VirtDisk.dll';
VIRTUAL_STORAGE_TYPE_DEVICE_UNKNOWN = 0;
//Device type is unknown or not valid.
VIRTUAL_STORAGE_TYPE_DEVICE_ISO = 1;
//Internal use only. Not supported.
VIRTUAL_STORAGE_TYPE_DEVICE_VHD = 2;
//Virtual hard disk device type.
CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_SECTOR_SIZE = $200;
// CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_BLOCK_SIZE = $0;
CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_BLOCK_SIZE = $200000;
var
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT: TGUID;
// '{EC984AEC-A0F9-47e9-901F-71415A66345B}';
VIRTUAL_STORAGE_TYPE_VENDOR_UNKNOWN : TGUID;
//= 0;
type
/////////////////////////////////////////////////////////
// typedef struct _VIRTUAL_STORAGE_TYPE {
// ULONG DeviceId;
// GUID VendorId;
// } VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE;
_VIRTUAL_STORAGE_TYPE =
record
DeviceId: ULONG;
VendorId: TGUID;
end;
VIRTUAL_STORAGE_TYPE = _VIRTUAL_STORAGE_TYPE;
PVIRTUAL_STORAGE_TYPE = ^_VIRTUAL_STORAGE_TYPE;
////////////////////////////////////////////////////////
// typedef enum _VIRTUAL_DISK_ACCESS_MASK {
// VIRTUAL_DISK_ACCESS_ATTACH_RO = 0x00010000,
// VIRTUAL_DISK_ACCESS_ATTACH_RW = 0x00020000,
// VIRTUAL_DISK_ACCESS_DETACH = 0x00040000,
// VIRTUAL_DISK_ACCESS_GET_INFO = 0x00080000,
// VIRTUAL_DISK_ACCESS_CREATE = 0x00100000,
// VIRTUAL_DISK_ACCESS_METAOPS = 0x00200000,
// VIRTUAL_DISK_ACCESS_READ = 0x000d0000,
// VIRTUAL_DISK_ACCESS_ALL = 0x003f0000,
// VIRTUAL_DISK_ACCESS_WRITABLE = 0x00320000
// } VIRTUAL_DISK_ACCESS_MASK;
_VIRTUAL_DISK_ACCESS_MASK = (
VIRTUAL_DISK_ACCESS_ATTACH_RO = $00010000,
VIRTUAL_DISK_ACCESS_ATTACH_RW = $00020000,
VIRTUAL_DISK_ACCESS_DETACH = $00040000,
VIRTUAL_DISK_ACCESS_GET_INFO = $00080000,
VIRTUAL_DISK_ACCESS_CREATE = $00100000,
VIRTUAL_DISK_ACCESS_METAOPS = $00200000,
VIRTUAL_DISK_ACCESS_READ = $000d0000,
VIRTUAL_DISK_ACCESS_ALL = $003f0000,
VIRTUAL_DISK_ACCESS_WRITABLE = $00320000
);
VIRTUAL_DISK_ACCESS_MASK = _VIRTUAL_DISK_ACCESS_MASK;
PVIRTUAL_DISK_ACCESS_MASK = ^_VIRTUAL_DISK_ACCESS_MASK;
/////////////////////////////////////////////////////////////////////////
// typedef enum _CREATE_VIRTUAL_DISK_FLAG {
// CREATE_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
// CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION = 0x00000001
// } CREATE_VIRTUAL_DISK_FLAG;
_CREATE_VIRTUAL_DISK_FLAG = (
CREATE_VIRTUAL_DISK_FLAG_NONE = $00000000,
CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION = $00000001
);
CREATE_VIRTUAL_DISK_FLAG = _CREATE_VIRTUAL_DISK_FLAG;
PCREATE_VIRTUAL_DISK_FLAG = ^_CREATE_VIRTUAL_DISK_FLAG;
////////////////////////////////////////////////////////////////
// typedef enum _CREATE_VIRTUAL_DISK_VERSION {
// CREATE_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
// CREATE_VIRTUAL_DISK_VERSION_1 = 1
// } CREATE_VIRTUAL_DISK_VERSION;
_CREATE_VIRTUAL_DISK_VERSION = (
CREATE_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
CREATE_VIRTUAL_DISK_VERSION_1 = 1
);
CREATE_VIRTUAL_DISK_VERSION = _CREATE_VIRTUAL_DISK_VERSION;
PCREATE_VIRTUAL_DISK_VERSION= ^_CREATE_VIRTUAL_DISK_VERSION;
////////////////////////////////////////////////////////////////////////////////
// typedef struct _CREATE_VIRTUAL_DISK_PARAMETERS {
// CREATE_VIRTUAL_DISK_VERSION Version;
// union {
// struct {
// GUID UniqueId;
// ULONGLONG MaximumSize;
// ULONG BlockSizeInBytes;
// ULONG SectorSizeInBytes;
// PCWSTR ParentPath;
// PCWSTR SourcePath;
// } Version1;
// } ;
//} CREATE_VIRTUAL_DISK_PARAMETERS, *PCREATE_VIRTUAL_DISK_PARAMETERS;
TCreateVirtualDiskVersion1 =
packed record
UniqueId: TGUID;
MaximumSize: ULONGLONG;
BlockSizeInBytes: ULONG;
SectorSizeInBytes: ULONG;
ParentPath: Pointer;
SourcePath: Pointer;
end;
_CREATE_VIRTUAL_DISK_PARAMETERS =
record
Version: _CREATE_VIRTUAL_DISK_VERSION;
case Integer
of
0: (Version1: TCreateVirtualDiskVersion1);
end;
CREATE_VIRTUAL_DISK_PARAMETERS = _CREATE_VIRTUAL_DISK_PARAMETERS;
PCREATE_VIRTUAL_DISK_PARAMETERS = ^_CREATE_VIRTUAL_DISK_PARAMETERS;
{
DWORD CreateVirtualDisk(
__in PVIRTUAL_STORAGE_TYPE VirtualStorageType,
__in PCWSTR Path,
__in VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask,
__in PSECURITY_DESCRIPTOR SecurityDescriptor,
__in CREATE_VIRTUAL_DISK_FLAG Flags,
__in ULONG ProviderSpecificFlags,
__in PCREATE_VIRTUAL_DISK_PARAMETERS Parameters,
__in LPOVERLAPPED Overlapped,
__out PHANDLE Handle
);
}
function CreateVirtualDisk(VirtualStorageType: PVIRTUAL_STORAGE_TYPE;
Path: PWideChar;
VirtualDiskAccessMask: VIRTUAL_DISK_ACCESS_MASK;
SecurityDescriptor: PSECURITY_DESCRIPTOR;
Flags: CREATE_VIRTUAL_DISK_FLAG;
ProviderSpecificFlags: ULong;
Parameters: PCREATE_VIRTUAL_DISK_PARAMETERS;
Overlapped: POverlapped;
Handle: PHandle): Cardinal;
stdcall external '
VirtDisk.dll'
name '
CreateVirtualDisk';
implementation
initialization
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT:= StringToGUid('
{EC984AEC-A0F9-47e9-901F-71415A66345B}');
end.