Previous Next

ZwDeleteKey

The ZwDeleteKey routine deletes an open key from the registry.

NTSTATUS 
  ZwDeleteKey(
    IN HANDLE  KeyHandle
    );

Parameters

KeyHandle
Hhandle a registry key. The handle is created by a successful call to ZwCreateKey or ZwOpenKey.

Headers

Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.

Return Value

ZwDeleteKey returns an NTSTATUS value. Possible return values include:

STATUS_SUCCESS
STATUS_ACCESS_DENIED
STATUS_INVALID_HANDLE

Comments

The key must have been opened for DELETE access for a deletion to succeed; the DesiredAccess value KEY_ALL_ACCESS includes DELETE access. The actual storage for the key is deleted when the last handle to the key is closed.

A call to ZwDeleteKey causes the handle that is specified in the KeyHandle parameter, and all other handles to the deleted key, to become invalid.

Callers of ZwDeleteKey must be running at IRQL = PASSIVE_LEVEL.

See Also

ZwClose, ZwCreateKey, ZwOpenKey