<div class="content" name="CreatePolicy" uuid="a9c3c4a4-b1df-4559-9097-f1222eb89b0b"><p>The CreatePolicy method creates a new <a href="e371cc74-bf4c-4870-8afe-5062cc628b4f#gt_ce127d6a-8b12-40d6-b9c9-cf544c3ffd08" data-linktype="relative-path">resource allocation policy
(RAP)</a>.</p><dl>
<dd>
<div><pre> [id(2), helpstring(&#34;method CreatePolicy&#34;)] HRESULT CreatePolicy(
   [in] BSTR bstrPolicyInfo
 );
</pre></div>
</dd></dl><p><b>bstrPolicyInfo: </b>A string that specifies the
new policy to be created in the form of a <a href="e6be8e0b-2ecb-4305-8f7c-ac378cc1900f" data-linktype="relative-path">Policy element</a> (section
2.2.5.21). For an example, see <a href="4600dd8b-3ef5-4390-9bfd-c291a6f45080" data-linktype="relative-path">Policy Example</a> (section
4.2.19).</p><dl>
<dd>
<p>If this parameter is NULL, <b>E_INVALIDARG</b> MUST
be returned.</p>
</dd></dl><p><b>Return Values: </b>This method returns 0x00000000
for success or a negative <a href="e371cc74-bf4c-4870-8afe-5062cc628b4f#gt_799103ab-b3cb-4eab-8c55-322821b2b235" data-linktype="relative-path">HRESULT</a>
value (in the following table or in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/705fb797-2175-4a90-b5a3-3918024b10b8" data-linktype="relative-path">2.1.1</a>)
if an error occurs.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 S_OK</td>
  <td>Operation successful.</td>
 </tr><tr>
  <td>0x80070057 E_INVALIDARG</td>
  <td>One or more arguments are invalid.</td>
 </tr><tr>
  <td>0xC1FF006F WRM_ERR_ID_VALUE</td>
  <td>The specified name contains characters that are invalid. The name cannot start with a hyphen &#34;-&#34;, cannot contain spaces, and cannot contain any of the following characters:   \   / ? * | : &lt; &gt; &#34; , ;</td>
 </tr><tr>
  <td>0xC1FF0070 WRM_ERR_TAGS_NOT_IN_ORDER</td>
  <td>The XML data that is maintained by the management service is invalid or cannot be processed.&lt;105&gt;</td>
 </tr><tr>
  <td>0xC1FF00CA WRM_ERR_POLICYID_ALREADY_EXISTS</td>
  <td>The request has been aborted because a RAP with the specified name already exists.</td>
 </tr><tr>
  <td>0xC1FF00DF WRM_ERR_POLICY_LIMIT_EXCEEDED</td>
  <td>The request has been aborted because the total number of RAPs has exceeded an implementation-defined limit.&lt;106&gt;</td>
 </tr><tr>
  <td>0xC1FF00E3 WRM_ERR_CANNOT_CREATE_RESERVED_POLICY</td>
  <td>A user created policy cannot have the same name as that of a built-in policy.</td>
 </tr><tr>
  <td>0xC1FF012E WRM_ERR_RESOURCEGROUPID_INVALID</td>
  <td>The request has been aborted because the process matching criteria (PMC) name could not be found.</td>
 </tr></tbody></table>
</dd></dl><p>Additional <a href="a03f4cd5-ad33-46aa-94e7-2c9a92f02b6f" data-linktype="relative-path">IWRMPolicy</a> interface
methods are specified in section 3.2.4.7.</p></div>