The ZwDeleteKey routine deletes an open key from the registry.
NTSTATUS
ZwDeleteKey(
IN HANDLE KeyHandle
);
Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.
ZwDeleteKey returns an NTSTATUS value. Possible return values include:
STATUS_SUCCESS
STATUS_ACCESS_DENIED
STATUS_INVALID_HANDLE
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.