Поделиться через


IWbemBackupRestoreEx::Restore method

The IWbemBackupRestoreEx::Restore method deletes the contents of the current repository, and restores with the contents of a specified previous backup.

Because Windows Management Instrumentation (WMI) is the server for this interface and must be stopped to complete this operation successfully, the COM connection is broken if this call is successful.

Syntax

HRESULT Restore(
  [in] LPCWSTR strRestoreFromFile,
  [in] long    lFlags
);

Parameters

strRestoreFromFile [in]

Constant, null-terminated string of 16-bit Unicode characters that contains the file name of the file to be restored. The specified file should point to a file previously created with IWbemBackupRestoreEx::Backup.

lFlags [in]

One of the following flags from the WBEM_BACKUP_RESTORE_FLAGS enumeration.

WBEM_FLAG_BACKUP_RESTORE_DEFAULT (0)

Does not shut down active clients; returns an error if there are any.

WBEM_FLAG_BACKUP_RESTORE_FORCE_SHUTDOWN (1)

Shuts down any active clients.

Return value

This method returns an HRESULT that indicates the status of the method call. The following list lists the value contained within the HRESULT.

  • WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING
    Occurs when the flag is set to WBEM_FLAG_BACKUP_RESTORE_DEFAULT and there are still active clients.

  • WBEM_E_INVALID_PARAMETER
    One of the arguments is not valid.

  • WBEM_E_ACCESS_DENIED
    User does not have the right to perform this operation. For more information, see Maintaining WMI Security.

  • S_OK
    Method succeeded.

Remarks

The default method is the same as setting the force mode flag, which breaks all active connections. This results in remote procedure call (RPC) errors from the active COM connections into WMI—until connections are established.

Examples

The following C++ example shows how to call the IWbemBackupRestoreEx::Restore method.


    // The pInt variable is of type IWbemBackupRestoreEx*
    pInt->Restore(
         L"c:\\\\winnt\\system32\\wbem\\repository\\back.x", 
         WBEM_FLAG_BACKUP_RESTORE_DEFAULT
      );

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Wbemcli.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

Wbemsvc.dll