INFO: Registry Key Order Reversed After You Save/Restore Registry (260058)
The information in this article applies to:
- Microsoft Windows CE Operating System, Versions 2.12
- Microsoft Windows CE Operating System, Versions 2.11
- Microsoft Windows CE Operating System, Versions 3.0
This article was previously published under Q260058 SUMMARY
After you use the Windows CE functions RegCopyFile and RegRestoreFile to save and restore the contents of the registry to persistent storage, the order of keys in the registry is reversed.
This problem also occurs if you use the OEM-implemented functions WriteRegistryToOEM and ReadRegistryFromOEM to save and restore the contents of the registry.
MORE INFORMATION
Normally, the physical order of registry keys does not matter, except in cases where the order of values returned by registry enumeration functions is significant.
One registry branch where registry key enumeration order is important is the HKEY_LOCAL_MACHINE\Devices\BuiltIn branch. Unless the Order and/or Index value are set for device drivers loaded from this branch, Microsoft Windows CE may load devices in a different order afger the use of the RegRestoreFile or ReadRegistryFromOEM functions.
In the following example, the two entries for the serial driver load in reverse order after the use of the RegCopyFile, WriteRegistryToOEM, RegRestoreFile, or ReadRegistryFromOEMor functions. The result is that the settings for Serial2 are assigned to COM1, and settings for Serial are assigned to COM2.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial]
"DeviceArrayIndex"=dword:00000000
"Prefix"="COM"
"Dll"="Serial.Dll"
"Order"=dword:00000000
"DeviceType"=dword:00000000
"FriendlyName"="Serial Cable on COM1:"
"Irq"=dword:00000004
"IoBase"=dword:000003f8
"IoLen"=dword:00000008
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2]
"DeviceArrayIndex"=dword:00000002
"Prefix"="COM"
"Dll"="Serial.Dll"
"Order"=dword:00000000
"DeviceType"=dword:00000000
"FriendlyName"="Serial Cable on COM2:"
"Irq"=dword:00000003
"IoBase"=dword:000002f8
"IoLen"=dword:00000008
If you add Index and/or Order values to these registry keys, you can control the load order and device name assignment.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial]
"Order"=dword:00000000
"Index"=dword:01
"DeviceArrayIndex"=dword:00000000
"Prefix"="COM"
"Dll"="Serial.Dll"
"DeviceType"=dword:00000000
"FriendlyName"="Serial Cable on COM1:"
"Irq"=dword:00000004
"IoBase"=dword:000003f8
"IoLen"=dword:00000008
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2]
"Order"=dword:00000001
"Index"=dword:02
"DeviceArrayIndex"=dword:00000002
"Prefix"="COM"
"Dll"="Serial.Dll"
"DeviceType"=dword:00000000
"FriendlyName"="Serial Cable on COM2:"
"Irq"=dword:00000003
"IoBase"=dword:000002f8
"IoLen"=dword:00000008
The value of Order controls the actual load order of the drivers. The driver for Serial always loads and initializes before the driver for Serial2. This setting is critical for device drivers that provide a layer upon another device driver.
The value of Index defines the preferred device name index. The Serial driver sets this to 1 to request COM1, and Serial2 sets the index value to 2 to request COM2. In the absence of the Order value, the drivers may be loaded in any order, but the device manager attempts to assign the device name index per the Index value. It is important that all drivers with the same prefix use the Index value because any driver without a preferred Index value is assigned the next available index. If the value requested with Index is already assigned, the device manager chooses the next available index by using an increasing search.
Modification Type: | Minor | Last Reviewed: | 12/15/2003 |
---|
Keywords: | kbinfo kbKernBase kbRegistry KB260058 |
---|
|