共用方式為


IMSAdminBase::ChangePermissions

The IMSAdminBase::ChangePermissions method changes permissions on an open handle. If the handle was opened with write permission and you change it to read-only, this method will cause any callback methods registered to be called.

HRESULT ChangePermissions(
      METADATA_HANDLE hMDHandle,
      DWORD dwMDTimeOut,
      DWORD dwMDAccessRequested
);

Parameters

  • hMDHandle
    Specifies a handle to the metabase, as returned by the IMSAdminBase::OpenKey method.

  • dwMDTimeOut
    Specifies the time, in milliseconds, for the method to wait for the operation to succeed.

  • dwMDAccessRequested
    Specifies the new permissions for the handle. It must be one or both of the following values:

    Value

    Meaning

    METADATA_PERMISSION_READ

    Open the key for reading.

    METADATA_PERMISSION_WRITE

    Open the key for writing.

Return Values

Returns an HRESULT that contains one of the following values:

Value

Description

E_HANDLE

The metabase handle is invalid.

HRESULT_FROM_WIN32(ERROR_PATH_BUSY)

The path specified cannot be used at this time.

S_OK

The method succeeded.

Remarks

When you use this method to add permissions, you should follow the same rules that apply to IMSAdminBase::OpenKey. Timeout values should be short for this call; it is quite possible for two threads with read permission on the same data to attempt to update to write permission at the same time. Both will block until one read handle is closed.

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.