<div class="content" name="FormatEx2" uuid="e8429f7f-ea9b-46b3-a26a-8634953fb62f"><p>The FormatEx2 method <a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_ea22e521-1a4e-4ceb-8d64-f65fa6d0e63b" data-linktype="relative-path">formats</a> a <a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_528b06a4-e67c-43b3-a02d-8738858a691d" data-linktype="relative-path">file system</a> on a <a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_9a876829-33a1-4f0b-8b81-8552b7e5561c" data-linktype="relative-path">volume</a>.</p><dl>
<dd>
<div><pre> HRESULT FormatEx2(
   [in, unique, string] LPWSTR pwszFileSystemTypeName,
   [in] USHORT usFileSystemRevision,
   [in] ULONG ulDesiredUnitAllocationSize,
   [in, unique, string] LPWSTR pwszLabel,
   [in] DWORD Options,
   [out] IVdsAsync** ppAsync
 );
</pre></div>
</dd></dl><p><b>pwszFileSystemTypeName: </b>A null-terminated
Unicode string that contains the name of the file systems to format the volume
with.</p><p><b>usFileSystemRevision: </b>A 16-bit, binary-coded
decimal number that indicates the revision of the file system, if any. The
first two (most significant) digits (8 bits) indicate the major revision, and
the last two (least significant) digits (8 bits) indicate the minor revision.
For example, 0x0250 represents revision 2.50.</p><p><b>ulDesiredUnitAllocationSize: </b>The size, in
bytes, of the allocation unit for the file system. The value MUST be a power of
2. If the value is 0, a default allocation unit that is determined by the file
system type is used. The allocation unit range is file system-dependent.</p><p><b>pwszLabel: </b>A null-terminated Unicode string to
assign to the new file system. The maximum label size is file system-dependent.</p><p><b>Options: </b>The combination of any values, by
using a bitwise OR operator, that are defined in the <a href="a9f34bd8-9f15-4ff9-b4ff-8cf01f028628" data-linktype="relative-path">VDS_FORMAT_OPTION_FLAGS</a>
enumeration.</p><p><b>ppAsync: </b>A pointer to an <a href="97ea9c0f-5c8a-43e9-a9ee-deda29e2a09e" data-linktype="relative-path">IVdsAsync</a> 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 or
a non-error <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path"><span>HRESULT</span></a> (as specified
in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>)
to indicate success, or return an implementation-specific nonzero error code to
indicate failure. For the <a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_799103ab-b3cb-4eab-8c55-322821b2b235" data-linktype="relative-path">HRESULT</a>
values predefined by the Virtual Disk Service Remote Protocol, see section <a href="5102cc53-3143-4268-ba4c-6ea39e999ab4" data-linktype="relative-path">2.2.3</a>.</p><p>When the server receives this message, it MUST validate the
following parameter:</p><ul><li><p><span><span> 
</span></span>Verify that <i>ppAsync</i> is not NULL.</p>
</li><li><p><span><span> 
</span></span>Create a new async object that implements the IVdsAsync interface
with an output type of VDS_ASYNCOUT_FORMAT, and then set the pointer that <i>ppAsync</i>
references to the interface.</p>
</li><li><p><span><span> 
</span></span>Return an HRESULT 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. 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>Attempt to get exclusive access to the volume. If the server
fails to get exclusive access to the volume, and the VDS_FSOF_FORCE flag in the
<i>Options</i> parameter is not set to true, then the server MUST return
VDS_E_DEVICE_IN_USE.</p>
</li><li><p><span><span> 
</span></span>If the operating system is unable to format the device using the
file system type specified using the <i>type</i> parameter, then this method
MUST return VDS_E_INCOMPATIBLE_FILE_SYSTEM.</p>
</li><li><p><span><span> 
</span></span>If the target device\media is write-protected, then this method
MUST return VDS_E_MEDIA_WRITE_PROTECTED.</p>
</li><li><p><span><span> 
</span></span>If the <i>pwszLabel</i> parameter is incompatible with the file
system type specified using the <i>type</i> parameter, then the server MUST
return VDS_E_BAD_LABEL.</p>
</li><li><p><span><span> 
</span></span>If the specified file system type does not support <a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_551fedc1-b5b0-4bd2-b11f-86af801d1c7a" data-linktype="relative-path">quick formatting</a>, then the
server MUST return VDS_E_CANT_QUICK_FORMAT.</p>
</li><li><p><span><span> 
</span></span>If the specified file system type has a minimum volume size
requirement, and that requirement is not met, then the server MUST return
VDS_E_VOLUME_TOO_SMALL.</p>
</li><li><p><span><span> 
</span></span>If the specified file system type has a maximum volume size requirement,
and that requirement is not met, then the server MUST return
VDS_E_VOLUME_TOO_BIG.</p>
</li><li><p><span><span> 
</span></span>If the specified file system type has a minimum or maximum <a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_7a427e97-46a3-46de-91c3-bd52f8763a84" data-linktype="relative-path">cluster size</a> requirement,
and that requirement is not met, then the server MUST return
VDS_E_CLUSTER_SIZE_TOO_SMALL or VDS_E_CLUSTER_SIZE_TOO_BIG, respectively.</p>
</li><li><p><span><span> 
</span></span>If the specified file system type has a maximum <a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_feef37b3-c173-4f51-aab6-b55a6366259b" data-linktype="relative-path">cluster</a> count requirement,
and that requirement is not met, then the server MUST return
VDS_E_CLUSTER_COUNT_BEYOND_32BITS.</p>
</li></ul><p>The server MUST update the percentage completed value
periodically during the following sequence, and send progress notifications to
all clients. How often the percentage completed is updated, and at what point
in the sequence, is implementation specific. To send progress notifications to
the clients:</p><ul><li><p><span><span> 
</span></span>For each callback object registered in the list of callback
objects, call the callback object&#39;s IVdsAdviseSink::OnNotify (Opnum 3) method
with a <a href="4f29057f-ab32-4a3d-9fcb-00ba3457cb42" data-linktype="relative-path">VDS_NOTIFICATION</a>
structure with the following attributes:</p>
<ul><li><p><span><span>  </span></span><b>objectType</b>
member is VDS_NTT_FILE_SYSTEM.</p>
</li><li><p><span><span>  </span></span><b>FileSystem</b>
member is a <a href="e75c0a7b-53f3-439f-ad9c-2473b96998de" data-linktype="relative-path">VDS_FILE_SYSTEM_NOTIFICATION</a>
with the following attributes:</p>
<ul><li><p><span><span> 
</span></span><b>ulEvent</b> is VDS_NF_FILE_SYSTEM_FORMAT_PROGRESS.</p>
</li><li><p><span><span> 
</span></span><b>volumeId</b> is the <a href="9186f1ce-04de-4df2-a8cf-3925a02fcd47" data-linktype="relative-path">VDS_OBJECT_ID</a> of the
volume object</p>
</li><li><p><span><span> 
</span></span><b>dwPercentCompleted</b> is the percentage completed value.</p>
</li></ul></li></ul></li></ul><p>The server MUST perform the following in sequence:</p><ul><li><p><span><span> 
</span></span>Format the volume following the parameters specified to the
method.</p>
</li><li><p><span><span> 
</span></span>For each callback object that is registered in the list of
callback objects, call the callback object&#39;s <a href="04a70bf6-208d-463a-b0a4-cc96e198ded1" data-linktype="relative-path">IVdsAdviseSink::OnNotify</a>
(Opnum 3) method by using a VDS_NOTIFICATION structure that has the following
attributes:</p>
<ul><li><p><span><span>  </span></span>The
<b>objectType</b> member is VDS_NTT_VOLUME.</p>
</li><li><p><span><span>  </span></span>The
<b>Volume</b> member is a <a href="410540de-982d-4db1-991e-a73efed4e6f0" data-linktype="relative-path">VDS_VOLUME_NOTIFICATION</a>
with the following attributes:</p>
<ul><li><p><span><span> 
</span></span><b>ulEvent</b> is VDS_NF_VOLUME_MODIFY.</p>
</li><li><p><span><span> 
</span></span><b>volumeId</b> is the VDS_OBJECT_ID of this volume object.</p>
</li></ul></li></ul></li><li><p><span><span> 
</span></span>If VDS_FSOF_COMPRESSION is specified and the file system being
formatted supports compression, compress the file system after formatting is
complete.<a id="Appendix_A_Target_136"></a><a aria-label="Product behavior note 136" href="6b2552ee-ba27-409f-99a8-18841573327a#Appendix_A_136" data-linktype="relative-path">&lt;136&gt;</a></p>
</li><li><p><span><span> 
</span></span>Set the return code in the async object to an HRESULT indicating
failure or success.</p>
<ul><li><p><span><span>  </span></span>If
the server tried to compress the file systems after formatting but failed, the
return code MUST be set to VDS_S_VOLUME_COMPRESS_FAILED (HRESULT of
0x00042443).</p>
</li></ul></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></div>