<div class="content" name="AppCreate2" uuid="83f2707b-669f-429b-8674-ebccb338738e"><p>The AppCreate2 method creates a new application at the
specified <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_086b13f2-2715-4000-a16c-6acc3d59cc19" data-linktype="relative-path">metabase</a> path.</p><dl>
<dd>
<div><pre> HRESULT AppCreate2(
   [in, unique, string] LPCWSTR szMDPath,
   [in] DWORD dwAppMode
 );
</pre></div>
</dd></dl><p><b>szMDPath: </b> A pointer to a Unicode string that
contains the metabase path of the application. </p><p><b>dwAppMode: </b> An unsigned 32-bit integer value
indicating the process where the application will run. This parameter MUST be
set to one of the following values.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>eAppRunInProc 0x00000000</td>
  <td>The application runs in the IIS parent process.</td>
 </tr><tr>
  <td>eAppRunOutProcIsolated 0x00000001</td>
  <td>The application runs in its own process.</td>
 </tr><tr>
  <td>eAppRunOutProcInDefaultPool 0x00000002</td>
  <td>The application runs in a shared process with other applications outside of the IIS parent process.</td>
 </tr></tbody></table>
</dd></dl><p><b>Return Values: </b> A signed 32-bit value that
indicates return status. If the method returns a negative value, it failed. If
the 12-bit facility code (bits 16–27) is set to 0x007, the value contains a
Win32 error code in the lower 16 bits. Zero or positive values indicate success,
with the lower 16 bits in positive nonzero values containing warnings or flags
defined in the method implementation. For more information about Win32 error
codes and <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a>
values, see <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.
</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>The call was successful.</td>
 </tr></tbody></table>
</dd></dl><p>The <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_e127848e-c66d-427d-b3aa-9f904fa4ada7" data-linktype="relative-path">opnum</a>
field value for this method is 9. </p><p>When processing this call, the server MUST do the following:</p><ul><li><p><span><span> 
</span></span>The <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a>
SHOULD validate that the metabase path specified in the <i>szMDPath</i>
parameter is a valid application path. <a id="Appendix_A_Target_28"></a><a aria-label="Product behavior note 28" href="88fd1df0-e63e-41ca-9bf3-bedcab57cd86#Appendix_A_28" data-linktype="relative-path">&lt;28&gt;</a></p>
</li><li><p><span><span> 
</span></span>Check that the path specified in <i>szMDPath</i> exists in the
metabase. If it does not, create it.</p>
</li><li><p><span><span> 
</span></span>If the path exists, check to see whether an application is
defined on the path. If an application is already defined at this metabase path
and the value of <a href="5df9ca57-2a81-4ff4-97d5-fd39aa6731af" data-linktype="relative-path">MD_APP_ISOLATED</a>
matches that specified by the client in the <i>dwAppMode</i> parameter, return
S_OK. If the value does not match, delete the current application (see section <a href="f4683981-4b25-46fa-9017-90cb0f08466c" data-linktype="relative-path">3.7.4.2</a>).</p>
</li><li><p><span><span> 
</span></span>Create the new application. </p>
</li><li><p><span><span> 
</span></span>Set the MD_APP_ISOLATED property on the specified metabase path
to the value specified in the <i>dwAppMode</i> parameter.</p>
</li><li><p><span><span> 
</span></span>Set the <a href="941aefe0-7996-4614-ac1e-b899c6ff8b7e" data-linktype="relative-path">MD_APP_ROOT</a>
property on the specified metabase path to the value of <i>szMDPath</i> without
any trailing &#39;/&#39; if one was specified.</p>
</li></ul></div>