<div class="content" name="AddNtmsMediaType" uuid="6e5398ec-c151-49c9-97ef-2883e2a0e458"><p>The AddNtmsMediaType method MUST add a media type to a
library if there is not currently a relation in the library. The method MUST
create the system media pools (FREE, IMPORT, and UNRECOGNIZED) if they do not
exist.</p><dl>
<dd>
<div><pre> HRESULT AddNtmsMediaType(
   [in] LPNTMS_GUID lpMediaTypeId,
   [in] LPNTMS_GUID lpLibId
 );
</pre></div>
</dd></dl><p><b>lpMediaTypeId: </b>A pointer to the identifier of
a media type to add to the library.</p><p><b>lpLibId: </b> A pointer to the identifier of the
library to which the media type is to be added.</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><tr>
  <td>0x80070005 ERROR_ACCESS_DENIED</td>
  <td>NTMS_MODIFY_ACCESS to the library is denied; other security errors are possible, but indicate a security subsystem error.</td>
 </tr><tr>
  <td>0x80070008 ERROR_NOT_ENOUGH_MEMORY</td>
  <td>An allocation failure occurred during processing.</td>
 </tr><tr>
  <td>0x80070057 ERROR_INVALID_PARAMETER</td>
  <td>The media type or library identifiers are missing.</td>
 </tr><tr>
  <td>0x800710CD ERROR_INVALID_LIBRARY</td>
  <td>The library identifier is invalid.</td>
 </tr><tr>
  <td>0x800710D9 ERROR_DATABASE_FAILURE</td>
  <td>The database is inaccessible or damaged.</td>
 </tr><tr>
  <td>0x800710DA ERROR_DATABASE_FULL</td>
  <td>The database is full.</td>
 </tr></tbody></table>
</dd></dl><p>If the specified media type is not in the library object&#39;s
list of already supported media types, the AddNtmsMediaType method adds the it
to the specified library. If the specified media type is already in the library
object&#39;s list of already supported media types, the AddNtmsMediaType method
will not add the it to the specified library also it will not return error
because of this. AddNtmsMediaType then creates the system media pools if they
do not exist.</p><p>If the specified media type is not in the library object&#39;s
list of already supported media types, the AddNtmsMediaType method adds it to
the specified library. If the specified media type is already in the library
object&#39;s list of supported media types, the specified media type is not added
to the library object&#39;s list. In both instances, AddNtmsMediaType creates the
system media pools if they do not exist.</p><p>Upon receiving this message, the server MUST verify that <i>lpLibId</i>
and <i>lpMediaTypeId</i> are not NULL. If parameter validation fails, the
server MUST immediately fail the operation and return ERROR_INVALID_PARAMETER
(0x80070057).</p><p>If parameter validation succeeds, the server MUST verify
that the user has the required access rights and that the library is enabled
and online. If the library is offline, the server MUST return
ERROR_LIBRARY_OFFLINE (0x800710D1).</p></div>