<div class="content"><p> </p><p>The CreateVDisk method defines a new <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_1fbc35d5-bcf5-4ce7-9449-4197a1671440" data-linktype="relative-path">virtual
disk</a></span>. This method creates a virtual disk file to be used as the <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_432d7a86-d2ca-4977-8189-d28b54883d09" data-linktype="relative-path">backing
store</a></span> for the virtual disk.</p><dl>
<dd>
<div><pre> HRESULT CreateVDisk(
   [in] PVIRTUAL_STORAGE_TYPE VirtualDeviceType,
   [in, string] LPWSTR pPath,
   [in, string, unique] LPWSTR pStringSecurityDescriptor,
   [in] CREATE_VIRTUAL_DISK_FLAG Flags,
   [in] ULONG ProviderSpecificFlags,
   [in] ULONG Reserved,
   [in] PVDS_CREATE_VDISK_PARAMETERS pCreateDiskParameters,
   [in, out, unique] IVdsAsync** ppAsync
 );
</pre></div>
</dd></dl><p><b>VirtualDeviceType: </b>Pointer to a <span><a href="83aab33f-b675-4b22-8c5f-fd6c3ed27df2" data-linktype="relative-path">VIRTUAL_STORAGE_TYPE (section 2.2.1.3.23)</a></span>
structure that specifies the type of virtual <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_511ca852-83e7-4a0c-8081-06e36436876b" data-linktype="relative-path">hard disk</a></span> to be
created.</p><p><b>pPath: </b>A NULL-terminated wide-character string
containing the name and directory path for the backing file to be created for
the virtual hard disk.</p><p><b>pStringSecurityDescriptor: </b>A NULL-terminated
wide-character string containing the security descriptor to be applied to the
virtual disk. Security descriptors MUST be in the Security Descriptor
Definition Language (see <span><a href="https://go.microsoft.com/fwlink/?LinkId=114214" data-linktype="external">[MSDN-SDDLforDevObj]</a></span>).<a id="Appendix_A_Target_77"></a><a aria-label="Product behavior note 77" href="6b2552ee-ba27-409f-99a8-18841573327a#Appendix_A_77" data-linktype="relative-path">&lt;77&gt;</a> If this parameter is NULL, the
security descriptor in the caller&#39;s access token (see <span><a href="https://go.microsoft.com/fwlink/?LinkId=208360" data-linktype="external">[MSFT-WSM/WEDWNK]</a></span>)
MUST be used.</p><p><b>Flags: </b>Bitmask of flags specifying how the
virtual disk is to be created.</p><p><b>ProviderSpecificFlags: </b>A bitmask of flags that
are specific to the type of virtual hard disk that is being surfaced. These
flags are provider-specific.<a id="Appendix_A_Target_78"></a><a aria-label="Product behavior note 78" href="6b2552ee-ba27-409f-99a8-18841573327a#Appendix_A_78" data-linktype="relative-path">&lt;78&gt;</a></p><p><b>Reserved: </b>The parameter is reserved for future
use and MAY be zero.<a id="Appendix_A_Target_79"></a><a aria-label="Product behavior note 79" href="6b2552ee-ba27-409f-99a8-18841573327a#Appendix_A_79" data-linktype="relative-path">&lt;79&gt;</a></p><p><b>pCreateDiskParameters: </b>Pointer to a <span><a href="e8b4357a-59a1-47cf-9c7b-1a64f6281575" data-linktype="relative-path">VDS_CREATE_VDISK_PARAMETERS (section 2.2.2.18.2.1)</a></span>
structure that contains the virtual hard disk creation parameters.</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. For the <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_799103ab-b3cb-4eab-8c55-322821b2b235" data-linktype="relative-path">HRESULT</a></span> values
predefined by the Virtual Disk Service Remote Protocol, see section <span><a href="5102cc53-3143-4268-ba4c-6ea39e999ab4" data-linktype="relative-path">2.2.3</a></span>.</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>VirtualDeviceType</i> is not NULL.</p>
</li><li><p><span><span> 
</span></span>Verify that <i>pPath</i> is not NULL.</p>
</li><li><p><span><span> 
</span></span>Verify that <i>pStringSecurityDescriptor</i> is not NULL.</p>
</li><li><p><span><span> 
</span></span>Verify that if there are multiple flags, the <i>Flags</i>
correspond to a bitwise OR of one or more flags specified in the <span><a href="4d1187e0-8140-4e7a-9e5f-b6304171c18b" data-linktype="relative-path">CREATE_VIRTUAL_DISK_FLAG (section 2.2.2.18.1.1)</a></span>
enumeration; otherwise it is just the one flag.</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_CREATE_VDISK and set the pointer <i>ppAsync</i>
references 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 method parameters to the operating system to create the
virtual disk.</p>
</li><li><p><span><span> 
</span></span>Set the return code in the async object to an HRESULT indicating
failure or success.</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 progress has been made.</p></div>