<div class="content" name="RestoreHistory" uuid="542437d9-179e-4273-90bc-c44a727be6e1"><p>The RestoreHistory method restores a <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_086b13f2-2715-4000-a16c-6acc3d59cc19" data-linktype="relative-path">metabase</a> history entry for
a specific history version.</p><dl>
<dd>
<div><pre> HRESULT RestoreHistory(
   [unique, in, string] LPCWSTR pszMDHistoryLocation,
   [in] DWORD dwMDMajorVersion,
   [in] DWORD dwMDMinorVersion,
   [in] DWORD dwMDFlags
 );
</pre></div>
</dd></dl><p><b>pszMDHistoryLocation: </b>A pointer to a Unicode
string containing the absolute path to the location of the history files for
the metabase. If an empty string is passed to this function, the server SHOULD
use the default history path.<a id="Appendix_A_Target_25"></a><a aria-label="Product behavior note 25" href="88fd1df0-e63e-41ca-9bf3-bedcab57cd86#Appendix_A_25" data-linktype="relative-path">&lt;25&gt;</a></p><p><b>dwMDMajorVersion: </b>An integer value containing
the predecimal version value of the history entry to restore from. If the <i>dwMDFlags</i>
parameter contains the MD_HISTORY_LATEST flag, this value MUST be set to zero.</p><p><b>dwMDMinorVersion: </b>An integer value containing
the postdecimal version value of the history entry to restore from. If the <i>dwMDFlags</i>
parameter contains the <b>MD_HISTORY_LATEST</b> flag, this value MUST be set to
zero.</p><p><b>dwMDFlags: </b>A set of bit flags specifying the
options to be executed during the RestoreHistory call.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>MD_HISTORY_LATEST 0x00000001</td>
  <td>Restore to the most recent history file. If this is set, the dwMDMajorVersion and dwMDMinorVersion parameters must be set to zero.</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><tr>
  <td>0x80070002 ERROR_FILE_NOT_FOUND</td>
  <td>The system cannot find the file specified.</td>
 </tr><tr>
  <td>0x80070003 ERROR_PATH_NOT_FOUND</td>
  <td>The system cannot find the path specified.</td>
 </tr><tr>
  <td>0x8007000E E_OUTOFMEMORY</td>
  <td>Ran out of memory.</td>
 </tr><tr>
  <td>0x80070008 ERROR_NOT_ENOUGH_MEMORY</td>
  <td>Not enough storage is available to process this command.</td>
 </tr><tr>
  <td>0x80070057 E_INVALIDARG</td>
  <td>One or more arguments are invalid.</td>
 </tr><tr>
  <td>0x80070013 ERROR_INVALID_DATA</td>
  <td>One or more arguments are invalid.</td>
 </tr><tr>
  <td>0x800703EC ERROR_INVALID_FLAGS</td>
  <td>Invalid flags were passed.</td>
 </tr><tr>
  <td>0x80070005 ERROR_ACCESS_DENIED</td>
  <td>Access is denied.</td>
 </tr><tr>
  <td>0x800CC802 MD_ERROR_INVALID_VERSION</td>
  <td>The version specified in metadata storage was not recognized.</td>
 </tr></tbody></table>
</dd></dl><p><b>Exceptions Thrown:</b> No exceptions are thrown
beyond those thrown by the underlying <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a> protocol <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>.</p><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 38. </p><p> When processing this call, the server MUST do the
following:</p><ul><li><p><span><span> 
</span></span>The server MUST restore the history from the location passed in
the <i>pszMDHistoryLocation</i> value. If this location does not exist the
server returns the HRESULT derived from the Win32 error code
ERROR_PATH_NOT_FOUND.</p>
</li><li><p><span><span> 
</span></span>If the <i>pszMDHistoryLocation</i> value passed in is an empty
string, the server uses the default history location as defined by the server
specific implementation.</p>
</li><li><p><span><span> 
</span></span>If the MD_HISTORY_LATEST flag is passed, the server MUST check
that <i>dwMDMajorVersion</i> and <i>dwMDMinorVersion</i> are 0 and return the
HRESULT derived from the Win32 error code E_INVALIDARG.</p>
</li><li><p><span><span> 
</span></span>If the version requested does not exist, the server MUST return
the MD_ERROR_INVALID_VERSION error code.</p>
</li><li><p><span><span> 
</span></span>If the <i>dwMDFlags</i> value contains anything beyond the
expected flag values, the server MUST return the ERROR_INVALID_FLAGS error
code.</p>
</li><li><p><span><span> 
</span></span>The server replaces the current metabase data with the data from
the history entry specified.</p>
</li></ul></div>