IVdsVolume::Shrink method (vds.h)

[Beginning with Windows 8 and Windows Server 2012, the Virtual Disk Service COM interface is superseded by the Windows Storage Management API.]

Reduces the size of the volume and all plexes, and returns the released extents to free space.

Syntax

HRESULT Shrink(
  [in]  ULONGLONG ullNumberOfBytesToRemove,
  [out] IVdsAsync **ppAsync
);

Parameters

[in] ullNumberOfBytesToRemove

The size of the reduction in bytes.

[out] ppAsync

The address of an IVdsAsync interface pointer. VDS initializes the interface on return. Callers must release the interface. Use this interface to cancel, wait for, or query the status of the operation. If IVdsAsync::Wait is called and a success HRESULT value is returned, the interfaces returned in the VDS_ASYNC_OUTPUT structure must be released by calling the IUnknown::Release method on each interface pointer. However, if Wait returns a failure HRESULT value, or if the pHrResult parameter of Wait receives a failure HRESULT value, the interface pointers in the VDS_ASYNC_OUTPUT structure are NULL and do not need to be released. You can test for success or failure HRESULT values by using the SUCCEEDED and FAILED macros defined in Winerror.h.

Return value

This method can return standard HRESULT values, such as E_INVALIDARG or E_OUTOFMEMORY, and VDS-specific return values. It can also return converted system error codes using the HRESULT_FROM_WIN32 macro. Errors can originate from VDS itself or from the underlying VDS provider that is being used. Possible return values include the following.

Return code/value Description
S_OK
The method completed successfully.
VDS_E_PROVIDER_CACHE_CORRUPT
0x8004241FL
The cache of the provider is corrupted. This indicates a software or communication problem inside a provider that caches information about the attached devices. The caller can use the IVdsHwProvider::Reenumerate method followed by the IVdsHwProvider::Refresh method to restore the cache.
VDS_E_CANNOT_SHRINK
0x8004251EL
The volume cannot be shrunk because the file system does not support it.
VDS_E_DISK_REMOVEABLE
0x8004255AL
The operation is not supported on removable media.
VDS_E_SHRINK_SIZE_LESS_THAN_MIN
0x80042573L
The specified shrink size is less than the minimum shrink size allowed.
VDS_E_SHRINK_SIZE_TOO_BIG
0x80042574L
The specified shrink size is too large and will cause the volume to be smaller than the minimum volume size.

Remarks

This method is a wrapper for the IVdsVolumeShrink::Shrink method. If you call IVdsVolume::Shrink, the value of the uNumberOfBytesToRemove parameter is used for the ullDesiredNumberOfReclaimableBytes and ullMinNumberOfReclaimableBytes parameters of IVdsVolumeShrink::Shrink.

Shrink and extend operations are supported only on NTFS and RAW volumes.

Use this method to shrink the file system and volume. If VDS fails to shrink the volume, it stops the operation without shrinking the file system.

Only one shrink or defragmentation operation can be performed at a time on each volume.Windows Server 2008 and Windows Vista:  Only one shrink or defragmentation operation can be performed at a time on a computer.

If uNumberOfBytesToRemove is zero, the method fails. Otherwise, VDS rounds uNumberOfBytesToRemove to a multiple of the file system cluster size.

Implementers must return a pointer to the IVdsAsync interface for this method, even if the call does not initiate an asynchronous operation.

You can use the IVdsVolumeShrink::QueryMaxReclaimableBytes method to estimate the number of bytes to be reclaimed by the shrink operation. However, QueryMaxReclaimableBytes can return more bytes than are actually available.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header vds.h
Library Uuid.lib

See also

IVdsAsync

IVdsVolume

IVdsVolume::Extend