WdfDriverOpenParametersRegistryKey method

[Applies to KMDF and UMDF]

The WdfDriverOpenParametersRegistryKey method opens the driver's Parameters registry key and retrieves a handle to a framework registry-key object that represents the key.

Syntax


NTSTATUS WdfDriverOpenParametersRegistryKey(
  [in]           WDFDRIVER              Driver,
  [in]           ACCESS_MASK            DesiredAccess,
  [in, optional] PWDF_OBJECT_ATTRIBUTES KeyAttributes,
  [out]          WDFKEY                 *Key
);

Parameters

Driver [in]

A handle to the driver's framework driver object that the driver obtained from a previous call to WdfDriverCreate or WdfGetDriver.

DesiredAccess [in]

An ACCESS_MASK-typed value that specifies an access mask for the Parameters registry key.

A KMDF driver typically requests KEY_READ, KEY_WRITE, or KEY_READ | KEY_WRITE.

If you are writing a UMDF driver, use the following table.

DeviceInstanceKeyTypeDesiredAccess

PLUGPLAY_REGKEY_DEVICE

KEY_READ

PLUGPLAY_REGKEY_DEVICE | WDF_REGKEY_DEVICE_SUBKEY

KEY_READ or KEY_READ | KEY_SET_VALUE

PLUGPLAY_REGKEY_DRIVER

KEY_READ

PLUGPLAY_REGKEY_DRIVER | WDF_REGKEY_DRIVER_SUBKEY

KEY_READ or KEY_READ | KEY_SET_VALUE

 

As a best practice, ask for only the types of access that your driver needs.

KeyAttributes [in, optional]

A pointer to a caller-allocated WDF_OBJECT_ATTRIBUTES structure that specifies object attributes for the framework registry-key object. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

Key [out]

A pointer to a location that receives a handle to a framework registry-key object.

Return value

WdfDriverOpenParametersRegistryKey returns STATUS_SUCCESS if the operation succeeds. Additional return values include:

Return codeDescription
STATUS_ACCESS_DENIED

A UMDF driver specified one of the following flags in the DesiredAccess parameter:

  • GENERIC_WRITE
  • KEY_CREATE_SUBKEY
  • WRITE_DAC

Because the above values are invalid for UMDF drivers, universal flags such as GENERIC_ALL and STANDARD_RIGHTS_ALL also cause WdfDriverOpenParametersRegistryKey to fail with this return value.

 

For more information about return values, see Framework Object Creation Errors.

This method might also return other NTSTATUS values.

A system bug check occurs if a KMDF driver specifies an invalid handle in Driver.

Remarks

The driver's Parameters key is located in the registry's Services tree. If the driver's Parameters key does not exist, the WdfDriverOpenParametersRegistryKey method creates it.

When the driver has finished using the Parameters registry key, the driver must call WdfRegistryClose.

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

Examples

The following code example opens a driver's Parameters registry key and obtains a handle to a framework registry-key object that represents the key.


WDFKEY hKey;

status = WdfDriverOpenParametersRegistryKey(
                                            Driver,
                                            STANDARD_RIGHTS_ALL,
                                            WDF_NO_OBJECT_ATTRIBUTES,
                                            &hKey
                                            );

Requirements

Target platform

Universal

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfdriver.h (include Wdf.h)

Library

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

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

See also

ACCESS_MASK
WDF_OBJECT_ATTRIBUTES
WdfDriverCreate
WdfDriverGetRegistryPath
WdfGetDriver
WdfRegistryClose

 

 

Send comments about this topic to Microsoft

Afficher:
© 2015 Microsoft