ExpandVirtualDisk function (virtdisk.h)

Increases the size of a fixed or dynamically expandable virtual hard disk (VHD).

Syntax

DWORD ExpandVirtualDisk(
  [in]           HANDLE                          VirtualDiskHandle,
  [in]           EXPAND_VIRTUAL_DISK_FLAG        Flags,
  [in]           PEXPAND_VIRTUAL_DISK_PARAMETERS Parameters,
  [in, optional] LPOVERLAPPED                    Overlapped
);

Parameters

[in] VirtualDiskHandle

A handle to the open virtual disk, which must have been opened using the VIRTUAL_DISK_ACCESS_METAOPS flag. For information on how to open a virtual disk, see the OpenVirtualDisk function.

[in] Flags

Must be the EXPAND_VIRTUAL_DISK_FLAG_NONE value of the EXPAND_VIRTUAL_DISK_FLAG enumeration.

[in] Parameters

A pointer to a valid EXPAND_VIRTUAL_DISK_PARAMETERS structure that contains expansion parameter data.

[in, optional] Overlapped

An optional pointer to a valid OVERLAPPED structure if asynchronous operation is desired.

Return value

Status of the request.

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is an error code. For more information, see System Error Codes.

Remarks

The ExpandVirtualDisk function performs the operation in-place, and therefore does not create a virtual disk.

The expand operation is valid only for fixed and expandable virtual disks and will invalidate a differencing virtual disk chain.

Expanding a virtual disk requires that the virtual disk be detached during the operation.

The caller must have READ|WRITE access to the backing store for the virtual disk.

For an expandable virtual disk, the ExpandVirtualDisk function may not result in a larger file because the size is virtual and would not actually grow physically until used.

If the virtual disk is expandable and the host volume does not have enough space for the new size, the ExpandVirtualDisk function can succeed anyway. Future writes to the virtual disk may fail if the host volume runs out of space as the virtual disk expands.

Requirements

Requirement Value
Minimum supported client Windows 7
Minimum supported server Windows Server 2008 R2
Target Platform Windows
Header virtdisk.h
Library VirtDisk.lib
DLL VirtDisk.dll

See also

About VHD

VHD Reference