Share via


IMSAdminBase::CopyKey

The IMSAdminBase::CopyKey method copies or moves a key, including its subkeys and data, to a specified destination. The copied or moved key becomes a subkey of the destination key.

HRESULT CopyKey(
      METADATA_HANDLE hMDSourceHandle,
      LPCWSTR pszMDSourcePath,
      METADATA_HANDLE hMDDestHandle,
      LPCWSTR pszMDDestPath,
      BOOL bMDOverwriteFlag,
      BOOL bMDCopyFlag
);

Parameters

  • hMDSourceHandle
    Specifies the handle of the key to be copied or moved. If the key is to be copied ( bMDCopyFlag is set to TRUE) hMDSourceHandle must have read permissions. If the key is to be moved ( bMDCopyFlag is set to FALSE), hMDSourceHandle must have read/write permissions.

  • pszMDSourcePath
    Points to a string that contains the path of the key to be copied or moved relative to the path of hMDSourceHandle. For example, if the handle references the /LM key, you could specify the Web services subkey using the path /W3SVC.

  • hMDDestHandle
    Specifies a handle with write permissions that specifies the destination of the moved or copied key.

  • pszMDDestPath
    Points to a string that contains the path of the new or moved key, relative to hMDDestHandle.

  • bMDOverwriteFlag
    Determines the behavior if the destination key already exists. If set to TRUE, the existing key and all of its data and children are deleted prior to copying or moving the source. If FALSE, the existing key, data, and children remain, and the source is merged with that data. In cases of data conflicts, the source data overwrites the destination data.

  • bMDCopyFlag
    Specifies whether to copy or move the specified key. If bMDCopyFlag is TRUE, the key is copied. If bMDCopyFlag is FALSE, the key is moved, and the source key is deleted from its original location.

Return Values

Returns an HRESULT that contains one of the following values:

Value

Description

E_ACCESSDENIED

Access is denied. Either the open handle does not have read or write permission as needed, or the user does not have sufficient permissions to perform the operation.

HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)

A key of that name already exists in the metabase.

E_INVALIDARG

The parameter is incorrect.

HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY)

Not enough memory is available to process this command.

HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)

The specified path was not found in the metabase.

S_OK

The method succeeded.

Requirements

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

Header: Declared in iadmw.h; include iiscnfg.h.