This documentation is archived and is not being maintained.

HrESERestoreOpenFile Function

EWS Managed API

Topic Last Modified: 2006-06-12

The HrESERestoreOpenFile function instructs the Exchange Storage Engine (ESE) to open the specified database or log file for restore. This function must be called for each file being restored. Note that for most file types, this function will respond indicating that the file is to be replaced using normal file-system operations. However, it is important that you tell ESE which database log files are being restored.

Applies To

ESEbcli2 DLL Functions Interface

HRESULT HrESERestoreOpenFile
        HCCX phccxRestoreContext,
        wchar* wszFileName,
        unsigned long cSections,
        void* rghFile


Input parameter. A handle to a restore context. The handle is passed to the various restore functions, and contains information about the current restore operations.


Input parameter. The name of the file to be restored.


Input parameter. The number of sections that the file will be constructed of. This must always be 1; restore operations using multiple sections are not supported.


Output parameter. An array of file handles for each section. The array will contain only one element.

The following return codes can be returned. To retrieve the error string for an ESE error, use the standard FormatMessage function. For the general errors hrErrorFromESECall and hrErrorFromCallbackCall, more information about the error is available using the standard GetLastError function.



ESE-specific error codes

ESE-specific error codes, as defined in esebkmsg.h.


Other Microsoft® Win32® or remote procedure call (RPC) errors.

This function will return an error, hrRestoreAtFileLevel (0xC7FF0FA5), for normal ESE database file types used in Microsoft Exchange. This error indicates that the application should use normal file-system operations to restore the file. The ESE restore functions HrESERestoreWriteFile and HrESERestoreClose are intended for use with application-specific files that ESE is not aware of.

Even though the function will return an error for most file types, the function must be called for all files being restored. The ESE must know which log files are being restored, so they can be used during database recovery operations.

For those files that do not return hrRestoreAtFileLevel, use the HrESERestoreWriteFile function to write data to the opened file, and use the HrESERestoreCloseFile function to close the file.

Applications that use this function must be run under a user account that has Microsoft Windows® server operating systems Backup and Restore privileges.