Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Accessing Registry Settings in a Driver

Accessing Registry Settings in a Driver

To increase the portability and reusability of a device driver, you can configure registry entries, which you should add to the driver's registry subkey. For example, you can define I/O-mapped memory addresses or settings for installable ISRs that the device driver loads dynamically. To access the entries in a device driver's registry key, the driver has to identify where its own settings are located. This is not necessarily the HKEY_LOCAL_MACHINEDriversBuiltIn key. However, the correct path information is available in the Key value that you can find under the HKEY_LOCAL_MACHINEDriversActive key in the loaded driver's subkey. Device Manager passes the path to the driver's DriversActive subkey to the XXX_Init function in the LPCTSTR pContext parameter. The device driver can then use this LPCTSTR value in a call to OpenDeviceKey to obtain a handle to the device's registry key. It is not necessary to read the Key values from the driver's DriversActive subkey directly. The handle returned by OpenDeviceKey points to the driver's registry key, which you can use like any other registry handle. Most importantly, do not forget to close the handle when it is no longer needed.

TIP

XXX_Init function and driver settings

The XXX_Init function is the best place to determine all configuration settings for a driver defined in the registry. Rather than accessing the registry repeatedly in subsequent stream function calls, it is good practice to store the configuration information in the device context created and returned to Device Manager in response to the XXX_Init call.

Оглавление книги


Генерация: 0.091. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз