WdfRegistryRemoveKey method

[Applies to KMDF and UMDF]

The WdfRegistryRemoveKey method removes the registry key that is associated with a specified framework registry-key object and then deletes the registry-key object.

Syntax


NTSTATUS WdfRegistryRemoveKey(
  [in] WDFKEY Key
);

Parameters

Key [in]

A handle to a registry-key object that represents an opened registry key.

Return value

WdfRegistryRemoveKey returns STATUS_SUCCESS if the operation succeeds. Otherwise, the method might return one of the following values:

Return codeDescription
STATUS_INVALID_DEVICE_REQUEST

WdfRegistryRemoveKey was not called at IRQL = PASSIVE_LEVEL.

STATUS_ACCESS_DENIED

The driver did not open the registry key with deletion access.

STATUS_NOT_IMPLEMENTED

See the Remarks section.

 

This method also might return other NTSTATUS values.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

Note  

From a KMDF driver, do not call WdfRegistryRemoveKey and then WdfRegistryClose on the same key. The WDFKEY is no longer valid after WdfRegistryRemoveKey returns.

 

While it is legal for a UMDF driver to call WdfRegistryRemoveKey, the call always returns STATUS_NOT_IMPLEMENTED. To delete the WDFKEY object, a UMDF driver should instead call WdfRegistryClose.

WdfRegistryRemoveKey does not return STATUS_SUCCESS if the specified key object represents a registry key that has subkeys. In other words, the driver must remove the subkeys first.

For more information about registry-key objects, see Using the Registry in Framework-Based Drivers.

Examples

The following code example removes a registry key and deletes the registry-key object.


NTSTATUS  status;

status = WdfRegistryRemoveKey(Key);

Requirements

Target platform

Universal

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfregistry.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

 

 

Send comments about this topic to Microsoft

Show: