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, //metabase handle to the source key.

  LPCWSTR pszMDSourcePath,   //path of the source relative to hMDSourceHandle.

  METADATA_HANDLE hMDDestHandle, //metabase handle to the destination.

  LPCWSTR pszMDDestPath,     //path of the destination, relative to hMDDestHandle.

  BOOL bMDOverwriteFlag,     //whether to overwrite or merge data with an existing version of the key.

  BOOL bMDCopyFlag       //whether to copy or move the key.

);

 

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
ERROR_ACCESS_DENIED 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.
ERROR_DUP_NAME A key of that name already exists in the metabase.
ERROR_INVALID_PARAMETER The parameter is incorrect.
ERROR_NOT_ENOUGH_MEMORY Not enough memory is available to process this command.
ERROR_PATH_NOT_FOUND The specified path was not found in the metabase.
ERROR_SUCCESS The method succeeded.