In the article Windows CE: Stream Interface Driver, XXX_Init() I presented the following function:
DWORD XXX_Init(LPCTSTR RegistryPath, DWORD dwBusContect) 
{
    HKEY hKey;
 
    RETAILMSG( 1, (TEXT("XXX_Init\n")));
    
    hKey = OpenDeviceKey(RegistryPath);
    if ( !hKey ) {
        RETAILMSG(1, (TEXT("Failed to open devkeypath,\r\n")));
    }
    else
    {
         // Read values from registry if needed
 
         RegCloseKey (hKey);
    }
 
    return TRUE;
}
But I didn’t really discuss the function OpenDeviceKey() and what it is doing.
The first parameter, in this case RegistryPath, to XXX_Init() is a string that contains the path to the Active registry key. The Active registry key is used by the device manager to track information about instances of loaded drivers.   The Active registry key isn't very valuable for your driver, but it can be used to find and open the registry key for your driver (example: HKEY_LOCAL_MACHINE\Driver\Builtin\MyDriver).
The Active registry key has a string in the Key value that contains the path to the registry key that caused the driver to be loaded. OpenDeviceKey() uses the RegistryPath value to find and open the registry key that caused the driver to be loaded (for example: HKEY_LOCAL_MACHINE\Drivers\Builtin\MyDriver).
This means that using the first parameter to XXX_Init() and OpenDeviceKey() will provide your driver access to the information in the registry for the instance of the driver (for example: HKEY_LOCAL_MACHINE\Drivers\Builtin\MyDriver).  This information may contain IRQ, base address of hardware, and other information that the driver may need.
Although you could use RegistryPath to open the Active key directly and read the Key value, Microsoft recommends using OpenDeviceKey() to avoid future compatibility problems.
Copyright © 2009 – Bruce Eitman
All Rights Reserved