<div class="content"><p> </p><p>The EncapsulateDiskEx method converts the specified <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_425be2e8-ca0d-45db-afba-d9daee040d07" data-linktype="relative-path">basic
disks</a></span> to dynamic <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_c4133b2a-a990-4042-ba44-7fda3090f118" data-linktype="relative-path">disks</a></span>. This is a
synchronous task.</p><dl>
<dd>
<div><pre> HRESULT EncapsulateDiskEx(
   [in] unsigned long affectedDiskCount,
   [in, size_is(affectedDiskCount)] 
     DISK_INFO_EX* affectedDiskList,
   [in] unsigned long affectedVolumeCount,
   [in, size_is(affectedVolumeCount)] 
     VOLUME_INFO* affectedVolumeList,
   [in] unsigned long affectedRegionCount,
   [in, size_is(affectedRegionCount)] 
     REGION_INFO_EX* affectedRegionList,
   [out] unsigned long* encapInfoFlags,
   [out] TASK_INFO* tinfo
 );
</pre></div>
</dd></dl><p><b>affectedDiskCount: </b>The number of elements
passed in the <i>affectedDiskList</i> array.</p><p><b>affectedDiskList: </b>An array of <span><a href="7d94d560-37f2-4031-8c3e-ecfd2dc1ec9f" data-linktype="relative-path">DISK_INFO_EX</a></span>
structures that specifies the disks to be encapsulated.</p><p><b>affectedVolumeCount: </b>The number of elements
passed in the <i>affectedVolumeList</i> array.</p><p><b>affectedVolumeList: </b>An array of <span><a href="651f7cad-50c2-4800-b646-a0c47c138724" data-linktype="relative-path">VOLUME_INFO</a></span>
structures that represents the <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_9a876829-33a1-4f0b-8b81-8552b7e5561c" data-linktype="relative-path">volumes</a></span> affected by
the encapsulation. If the number of affect volumes is zero, a pointer to a
zero-length array MUST be passed. This pointer MUST NOT be input as NULL.</p><p><b>affectedRegionCount: </b>The number of elements
passed in the <i>affectedRegionList</i> array.</p><p><b>affectedRegionList: </b>An array of <span><a href="9a20cc96-88c3-4194-9563-9778bea15376" data-linktype="relative-path">REGION_INFO_EX</a></span>
structures that represents the regions affected by the encapsulation. If the
number of affect regions is zero, a pointer to a zero-length array MUST be
passed. This pointer MUST NOT be input as NULL.</p><p><b>encapInfoFlags: </b>Bitmap of <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_425bcab9-7911-4eae-b414-624b7a51eb5f" data-linktype="relative-path">flags</a></span>
that provides information about the encapsulation. The value of this field is
generated by combining zero or more of the following applicable flags with a
logical OR operation.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>ENCAP_INFO_CANT_PROCEED</p>
  <p>0x00000001</p>
  </td>
  <td>
  <p>Encapsulation for disk did not succeed. Inspect the
  other values of <i>encapInfoFlags</i> to determine the reason.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_NO_FREE_SPACE</p>
  <p>0x00000002</p>
  </td>
  <td>
  <p>The <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_3080678a-2e28-4e28-af89-8c010325a7b2" data-linktype="relative-path">volume manager</a></span>
  could not find sufficient <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_4932fda9-4823-4a72-b4e7-629f89d8fd90" data-linktype="relative-path">free space</a></span> on the
  disk for encapsulation.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_BAD_ACTIVE</p>
  <p>0x00000004</p>
  </td>
  <td>
  <p>The disk contains an <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_37f8831a-72a8-4808-9a39-6949f7172de9" data-linktype="relative-path">active partition</a></span>
  from which the current operating system was not started.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_UNKNOWN_PART</p>
  <p>0x00000008</p>
  </td>
  <td>
  <p>The volume manager was unable to determine the type of
  a partition on the disk.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_FT_UNHEALTHY</p>
  <p>0x00000010</p>
  </td>
  <td>
  <p>The disk contains an unhealthy <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_98c2ba19-d0f7-4db1-b6c1-4e7323cc5bc0" data-linktype="relative-path">FT</a></span>
  set volume.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_FT_QUERY_FAILED</p>
  <p>0x00000020</p>
  </td>
  <td>
  <p>The volume manager was unable to obtain information
  about an FT set volume on the disk.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_REBOOT_REQD</p>
  <p>0x00000100</p>
  </td>
  <td>
  <p>Encapsulation of the disk will require a restart of
  the computer.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_CONTAINS_FT</p>
  <p>0x00000200</p>
  </td>
  <td>
  <p>The disk is part of an FT set volume.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_VOLUME_BUSY</p>
  <p>0x00000400</p>
  </td>
  <td>
  <p>The disk is currently in use.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_PART_NR_CHANGE</p>
  <p>0x00000800</p>
  </td>
  <td>
  <p>Encapsulation of the disk requires modification of the
  boot configuration.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_MIXED_PARTITIONS</p>
  <p>0x00001000</p>
  </td>
  <td>
  <p>Encapsulation of a <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_2fc866b7-7f83-479a-ad4e-fdffcbcff989" data-linktype="relative-path">GPT</a></span> disk that
  contains basic partitions mixed with nonbasic partitions is not supported.</p>
  </td>
 </tr><tr>
  <td>
  <p>ENCAP_INFO_OPEN_FAILED</p>
  <p>0x00002000</p>
  </td>
  <td>
  <p>Could not open a volume that resides on a disk in the
  set of disks specified for encapsulation.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p><b>tinfo: </b>A pointer to a <span><a href="d55c167e-c6ad-445f-951c-9ac2d0de7a11" data-linktype="relative-path">TASK_INFO</a></span>
structure that the client can use to track the progress of the request.</p><p><b>Return Values: </b>The method MUST return 0 or a
nonerror <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path"><span>HRESULT</span></a> on success, or
an implementation-specific nonzero error code on failure (as specified in <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>;
see also section <span><a href="31eea9e6-25b0-4309-8f4a-50c74fbedc9b" data-linktype="relative-path">2.2.1</a></span> for HRESULT
values predefined by the Disk Management Remote Protocol).</p><p>Upon receiving this message, the server MUST validate
parameters:</p><ol><li><p><span>    </span>Verify that <i>affectedDiskList</i>
is not NULL and <i>affectedDiskCount</i> is not 0.</p>
</li><li><p><span>    </span>For each
DISK_INFO_EX structure specified by <i>affectedDiskList</i>, verify that the
disk specified by <i>diskId</i> is in the list of storage objects and that <b>lastKnownState</b>
matches the <b>LastKnownState</b> field of the object.</p>
</li><li><p><span>    </span>Verify that no
other basic disks need to be encapsulated together with the disks specified by <i>affectedDiskList</i>.
</p>
</li><li><p><span>    </span>Verify that <i>affectedVolumeList</i>
is not NULL. If <i>affectedVolumeCount</i> is zero, a valid pointer to a
zero-length array for the <i>affectVolumeList</i> MUST be passed in.</p>
</li><li><p><span>    </span>Verify that <i>affectedRegionList</i>
is not NULL. If <i>affectedRegionCount</i> is zero, a valid pointer to a
zero-length array for the <i>affectRegionList</i> MUST be passed in.</p>
</li><li><p><span>    </span>Verify that the
list of basic volumes specified by <i>affectedVolumeList</i> matches the set of
<span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_e88c8bcf-42a7-41c6-b59a-e959ae01048d" data-linktype="relative-path">basic
volumes</a></span> residing on the disks specified by <i>affectedDiskList</i>. </p>
</li><li><p><span>    </span>Verify that <i>encapInfoFlags</i>
is not NULL. </p>
</li><li><p><span>    </span>Verify that <i>tinfo</i>
is not NULL. </p>
</li></ol><p>If parameter validation fails, the server MUST fail the
operation immediately, returning an appropriate error as its response to the
client.</p><p>Otherwise, the server MUST process the message as follows:</p><ol><li><p><span>    </span>Convert the
basic disks specified by affectedDiskList to dynamic:</p>
<ul><li><p><span><span>  </span></span>All
partitions and <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_a6adfe1b-35d0-404e-b2fb-4d45e9f579e0" data-linktype="relative-path">logical drives</a></span> that
reside on the basic disk are converted to <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_80affbd0-04b4-489e-be50-ddf9383e5d28" data-linktype="relative-path">dynamic volumes</a></span>.</p>
</li></ul></li><li><p><span>    </span>Wait for the
conversion to succeed or fail. </p>
</li><li><p><span>    </span>Fill in the <i>tinfo</i>
output parameter. </p>
<table><thead>
  <tr>
   <th>
   <p>TASK_INFO member</p>
   </th>
   <th>
   <p>Required for this operation</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>TASK_INFO::id</p>
  </td>
  <td>
  <p>Required.</p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::storageId</p>
  </td>
  <td>
  <p>Not required.</p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::createTime</p>
  </td>
  <td>
  <p>Not required.<a id="Appendix_A_Target_216"></a><a aria-label="Product behavior note 216" href="5f5043a3-9e6d-40cc-a05b-1a4a3617df32#Appendix_A_216" data-linktype="relative-path">&lt;216&gt;</a></p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::clientID</p>
  </td>
  <td>
  <p>Not required.<a id="Appendix_A_Target_217"></a><a aria-label="Product behavior note 217" href="5f5043a3-9e6d-40cc-a05b-1a4a3617df32#Appendix_A_217" data-linktype="relative-path">&lt;217&gt;</a></p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::percentComplete</p>
  </td>
  <td>
  <p>Required for any task that returns REQ_IN_PROGRESS.</p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::status</p>
  </td>
  <td>
  <p>Required.</p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::type</p>
  </td>
  <td>
  <p>Required if PercentageComplete is being used.</p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::error</p>
  </td>
  <td>
  <p>Required.</p>
  </td>
 </tr><tr>
  <td>
  <p>TASK_INFO::tflag</p>
  </td>
  <td>
  <p>Not required.<a id="Appendix_A_Target_218"></a><a aria-label="Product behavior note 218" href="5f5043a3-9e6d-40cc-a05b-1a4a3617df32#Appendix_A_218" data-linktype="relative-path">&lt;218&gt;</a></p>
  </td>
 </tr></tbody></table>
</li><li><p><span>    </span>Return a
response to the client containing <i>tinfo</i> and the status of the operation.
</p>
</li><li><p><span>    </span>Send the task
completion notification.<a id="Appendix_A_Target_219"></a><a aria-label="Product behavior note 219" href="5f5043a3-9e6d-40cc-a05b-1a4a3617df32#Appendix_A_219" data-linktype="relative-path">&lt;219&gt;</a></p>
</li></ol><p>If the operation is successful, the server MUST make the
following changes to the list of storage objects before returning the response.</p><ol><li><p><span>    </span>Modify the
converted disk objects to account for the change in type.</p>
</li><li><p><span>    </span>Create new
dynamic volume objects that correspond to the new dynamic volumes. </p>
</li><li><p><span>    </span>Create new <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_753cb2b4-3f5c-48f3-97ef-61612c40499e" data-linktype="relative-path">disk
region</a></span> objects for the new dynamic disks.</p>
</li><li><p><span>    </span>Delete disk
region objects of the old basic disks.<a id="Appendix_A_Target_220"></a><a aria-label="Product behavior note 220" href="5f5043a3-9e6d-40cc-a05b-1a4a3617df32#Appendix_A_220" data-linktype="relative-path">&lt;220&gt;</a></p>
</li><li><p><span>    </span>Modify <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_1b153cd0-e3f3-4383-bc66-d5ad482c9766" data-linktype="relative-path">drive
letter</a></span> objects to account for the change of volume owning them. </p>
</li><li><p><span>    </span>Modify file
system objects to account for the change of volume owning them. </p>
</li></ol><p>If the <span><a href="3c91641b-e5cd-409e-a445-2e4d61ae33c6#gt_ad3783b1-c0fd-46e0-9910-4a16bc6c9d00" data-linktype="relative-path">boot partition</a></span> is
among the disks being encapsulated, the server MUST store boot partition change
information on persistent storage (registry). The information MUST contain the
old (pre-encapsulation) and new (post-encapsulation) partition number of the
boot partition. The information is useful in case the client sends an <span><a href="3e05a907-5e41-439d-96bd-5b93a5ea276f" data-linktype="relative-path">IVolumeClient3::QueryChangePartitionNumbers</a></span>
message.</p></div>