<div class="content"><p> </p><p>The Expand method increases the size of a <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_1fbc35d5-bcf5-4ce7-9449-4197a1671440" data-linktype="relative-path">virtual
disk</a></span>. Expanding a virtual disk requires that the virtual disk be
detached during the operation. The virtual disk file is opened with READ|WRITE
privileges using the <span><a href="a0ad8aa3-805f-4af9-af3b-748520427819" data-linktype="relative-path">IVdsVDisk::Open</a></span>
method.<a id="Appendix_A_Target_147"></a><a aria-label="Product behavior note 147" href="6b2552ee-ba27-409f-99a8-18841573327a#Appendix_A_147" data-linktype="relative-path">&lt;147&gt;</a></p><dl>
<dd>
<div><pre> HRESULT Expand(
   [in] EXPAND_VIRTUAL_DISK_FLAG Flags,
   [in] ULONGLONG NewSize,
   [out] IVdsAsync** ppAsync
 );
</pre></div>
</dd></dl><p><b>Flags: </b>An <span><a href="41e07401-c8a9-4d99-ad37-9dfe81041c77" data-linktype="relative-path">EXPAND_VIRTUAL_DISK_FLAG (section 2.2.2.20.1.5)</a></span>
enumeration value that specifies how the virtual disk is to be compacted.</p><p><b>NewSize: </b>The desired size, in bytes, of the
expanded virtual disk.</p><p><b>ppAsync: </b>A pointer to an <span><a href="97ea9c0f-5c8a-43e9-a9ee-deda29e2a09e" data-linktype="relative-path">IVdsAsync (section 3.1.3.1)</a></span>
interface that, if the operation is successfully completed, receives the
IVdsAsync interface to monitor and control this operation. Callers MUST release
the interface when they are done with it.</p><p><b>Return Values: </b>The method MUST return zero to
indicate success, or return an implementation-specific nonzero error code to
indicate failure.</p><p>When the server receives this message, it MUST validate the
following parameters:</p><ul><li><p><span><span> 
</span></span>Verify that <i>Flags</i> is a bitwise OR of values from the
EXPAND_VIRTUAL_DISK_FLAG enumeration.</p>
</li><li><p><span><span> 
</span></span>Verify that <i>ppAsync</i> is not NULL.</p>
</li></ul><p>The server MUST perform the following:</p><ul><li><p><span><span> 
</span></span>Create a new async object implementing the IVdsAsync interface
with an output type of VDS_ASYNCOUT_EXPAND_VDISK and set the pointer <i>ppAsync</i>
to the interface.</p>
</li><li><p><span><span> 
</span></span>Return an <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path"><span>HRESULT</span></a> indicating
failure or success. Any errors encountered up through this point in processing
the operation are returned in this HRESULT.</p>
</li></ul><p>The server MUST then perform the following in sequence.
Errors generated in this sequence of steps are returned in the pHrResult
parameter to the IVdsAsync::Wait or IVdsAsyncQueryStatus methods.</p><ul><li><p><span><span> 
</span></span>Pass the input parameters to the operating system to expand the <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_c4133b2a-a990-4042-ba44-7fda3090f118" data-linktype="relative-path">disk</a></span>.</p>
</li><li><p><span><span> 
</span></span>Set the return code in the async object to an HRESULT indicating
failure or success of the operating system.</p>
</li><li><p><span><span> 
</span></span>If the task completed successfully, set the percentage completed
value in the async object to 100.</p>
</li><li><p><span><span> 
</span></span>Set the signal state in the async object to TRUE.</p>
</li></ul><p>At any point in the preceding sequence before the percentage
completed value in the async object is 100, the server MUST update the
percentage completed value if forward progress is made during the expand
operation.</p></div>