ZwDeleteKey function

The ZwDeleteKey routine deletes an open key from the registry.


  HANDLE KeyHandle



Handle to the registry key to be deleted. The handle is created by a successful call to ZwCreateKey or ZwOpenKey.

Return Value

ZwDeleteKey returns an NTSTATUS value. Possible return values include:


The handle must have been opened for DELETE access for this routine to succeed. For more information, see the DesiredAccess parameter for ZwCreateKey.

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. After a call to ZwDeleteKey invalidates the key handles, you must call ZwClose to close the key handles.

For more information about working with registry keys, see Using the Registry in a Driver.

Note If the call to this function occurs in user mode, you should use the name "NtDeleteKey" instead of "ZwDeleteKey".
For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.


Windows version Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
DDI compliance rules IrqlZwPassive, PowerIrpDDis, ZwRegistryCreate, ZwRegistryOpen, HwStorPortProhibitedDDIs, ZwRegistryCreate(storport), ZwRegistryOpen(storport)

See Also

Using Nt and Zw Versions of the Native System Services Routines