共用方式為


IMSAdminBase::SetData

The IMSAdminBase::SetData method sets a data item. If data with that identifier does not already exist, this method creates and inserts a data item into the list of data items of that type. If data with that identifier already exists, this method sets the new data value. Duplicate data identifiers are not valid even if the entries are of different user types or data types.

HRESULT SetData(
      METADATA_HANDLE hMDHandle,
      LPCWSTR pszMDPath,
      PMETADATA_RECORD pmdrMDData
);

Parameters

  • hMDHandle
    Specifies a handle with write permissions as returned by the IMSAdminBase::OpenKey method. METADATA_MASTER_ROOT_HANDLE is not valid for this operation.

  • pszMDPath
    Specifies a string that contains the path of the key that receives the entry, relative to the path of hMDHandle. For example, if the handle references the /LM key, you could specify the Web services subkey by using the path /W3SVC.

  • pmdrMDData
    Points to a METADATA_RECORD structure that contains the data to set. All the structure Parameters must be filled except dwMDDataTag.

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.

MD_ERROR_CANNOT_REMOVE_SECURE_ATTRIBUTE

Cannot set data to be not secure when a secure value exists.

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.