Compartilhar via


IMSAdminBase::CopyData

The IMSAdminBase::CopyData method copies or moves data associated with the source key to the destination key. You can also specify whether the method copies the key's inherited data.

HRESULT CopyData(
      METADATA_HANDLE hMDSourceHandle,
      LPCWSTR pszMDSourcePath,
      METADATA_HANDLE hMDDestHandle,
      LPCWSTR pszMDDestPath,
      DWORD dwMDAttributes,
      DWORD dwMDUserType,
      DWORD dwMDDataType,
      BOOL bMDCopyFlag
);

Parameters

  • hMDSourceHandle
    Specifies METADATA_MASTER_ROOT_HANDLE, or a handle with read permission returned by the IMSAdminBase::OpenKey method.

  • pszMDSourcePath
    Points to a string that contains the path of the key with which the source data is associated, 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, returned by IMSAdminBase::OpenKey, that has write permission. METADATA_MASTER_ROOT_HANDLE is not a valid value for this parameter.

  • pszMDDestPath
    Points to the path of the key for data to be copied to, relative to the path of hMDDestHandle.

  • dwMDAttributes
    The flags, contained in the METADATA_RECORD structure, used to get the data.

  • dwMDUserType
    A DWORD that specifies the user type of the data. If not set to ALL_METADATA, only metadata of the specified user type will be copied or moved. The following user types are defined for IIS:

    User type

    Meaning

    ALL_METADATA

    Copy or move all data, regardless of user type.

    ASP_MD_UT_APP

    The entry contains information specific to ASP application configuration.

    IIS_MD_UT_FILE

    Copy or move only data specific to a file, such as access permissions or logon methods.

    IIS_MD_UT_SERVER

    Copy or move only data specific to the server, such as ports in use and IP addresses.

    IIS_MD_UT_WAM

    The entry contains information specific to Web application management.

  • dwMDDataType
    A DWORD that specifies the type of data to retrieve. If dwMDDataType is not set to ALL_METADATA, only metadata of the specified type will be copied or moved. This parameter can be one of the following values:

    Data type

    Meaning

    ALL_METADATA

    Copy or move all data, regardless of type.

    BINARY_METADATA

    Binary data in any form.

    DWORD_METADATA

    An unsigned 32-bit number.

    EXPANDSZ_METADATA

    A null-terminated string that contains unexpanded environment variables, such as %PATH%.

    MULTISZ_METADATA

    An array of null-terminated strings, terminated by two null characters.

    STRING_METADATA

    A null-terminated ASCII string.

  • bMDCopyFlag
    A Boolean value that specifies whether to copy or move the data. If this parameter is set to TRUE, the data is copied. If it is FALSE, the data is moved. If dwMDAttributes contains the flag METADATA_INHERIT, this parameter must be set to TRUE.

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.

E_INVALIDARG

The parameter is incorrect.

HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY)

There is not enough memory to complete the operation.

HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)

The specified path is not found.

S_OK

The method succeeded.

Remarks

If inherited data is copied, (if dwMDAttributes specifies the METADATA_INHERIT flag) it is copied to the destination key, not to the corresponding parent keys.

The handle, METADATA_MASTER_ROOT_HANDLE, provides no guarantee against multiple thread access. If your application requires a constant data state, use a handle returned by IMSAdminBase::OpenKey.

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.