3.1.4.28 RenameKey (Opnum 8)

The RenameKey method renames a node in the metabase.

 HRESULT RenameKey(
   [in] METADATA_HANDLE hMDHandle,
   [unique, in, string] LPCWSTR pszMDPath,
   [unique, in, string] LPCWSTR pszMDNewName
 );

hMDHandle: An unsigned 32-bit integer value containing an open metabase handle specifying the key to be renamed.

pszMDPath: A pointer to a Unicode string that contains the path of the node to be renamed, relative to the path of the hMDHandle parameter.

pszMDNewName: A pointer to a string that contains the new name for the node.

Return Values: A signed 32-bit value that indicates return status. If the method returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or positive values indicate success, with the lower 16 bits in positive nonzero values containing warnings or flags defined in the method implementation. For more information about Win32 error codes and HRESULT values, see [MS-ERREF].

Return value/code

Description

0x00000000

S_OK

The call was successful.

0x80070003

ERROR_PATH_NOT_FOUND

The system cannot find the path specified.

0x80070005

E_ACCESSDENIED

General access denied error.

0x80070006

ERROR_INVALID_HANDLE

The handle is invalid.

0x80070057

E_INVALIDARG

An invalid parameter value was specified.

0x800700B7

ERROR_ALREADY_EXISTS

A key of that name already exists in the database.

The opnum field value for this method is 8.

When processing this call, the server MUST do the following:

  • Check the handle. This handle is valid if it is either the master root handle or a handle returned from a previous OpenKey call. If the handle is invalid, return ERROR_INVALID_HANDLE.

  • The server SHOULD check whether the handle was opened for write access. If not, return E_ACCESSDENIED.<18>

  • Check the path of the node indicated by hMDHandle and pszMDPath. If the path does not exist, return ERROR_PATH_NOT_FOUND.

  • If the new node name would be the same as an existing node name, return ERROR_ALREADY_EXISTS.

  • Rename the  node without modifying the data.