Microsoft KB Archive/260058

{|
 * width="100%"|

INFO: Registry Key Order Reversed After You Save/Restore Registry

 * }

Q260058

-

The information in this article applies to:


 * Microsoft Windows CE Operating System versions 2.11, 2.12, 3.0

-

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] &quot;DeviceArrayIndex&quot;=dword:00000000 &quot;Prefix&quot;=&quot;COM&quot; &quot;Dll&quot;=&quot;Serial.Dll&quot; &quot;Order&quot;=dword:00000000 &quot;DeviceType&quot;=dword:00000000 &quot;FriendlyName&quot;=&quot;Serial Cable on COM1:&quot; &quot;Irq&quot;=dword:00000004 &quot;IoBase&quot;=dword:000003f8 &quot;IoLen&quot;=dword:00000008

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2] &quot;DeviceArrayIndex&quot;=dword:00000002 &quot;Prefix&quot;=&quot;COM&quot; &quot;Dll&quot;=&quot;Serial.Dll&quot; &quot;Order&quot;=dword:00000000 &quot;DeviceType&quot;=dword:00000000 &quot;FriendlyName&quot;=&quot;Serial Cable on COM2:&quot; &quot;Irq&quot;=dword:00000003 &quot;IoBase&quot;=dword:000002f8 &quot;IoLen&quot;=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] &quot;Order&quot;=dword:00000000 &quot;Index&quot;=dword:01 &quot;DeviceArrayIndex&quot;=dword:00000000 &quot;Prefix&quot;=&quot;COM&quot; &quot;Dll&quot;=&quot;Serial.Dll&quot; &quot;DeviceType&quot;=dword:00000000 &quot;FriendlyName&quot;=&quot;Serial Cable on COM1:&quot; &quot;Irq&quot;=dword:00000004 &quot;IoBase&quot;=dword:000003f8 &quot;IoLen&quot;=dword:00000008

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2] &quot;Order&quot;=dword:00000001 &quot;Index&quot;=dword:02 &quot;DeviceArrayIndex&quot;=dword:00000002 &quot;Prefix&quot;=&quot;COM&quot; &quot;Dll&quot;=&quot;Serial.Dll&quot; &quot;DeviceType&quot;=dword:00000000 &quot;FriendlyName&quot;=&quot;Serial Cable on COM2:&quot; &quot;Irq&quot;=dword:00000003 &quot;IoBase&quot;=dword:000002f8 &quot;IoLen&quot;=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.

Additional query words:

Keywords : kbKernBase kbRegistry kbSDKWin32 kbOSWinCE210 _IK kbGrpDSKernBase

Issue type : kbinfo

Technology : kbOSWinCE kbWinCESearch kbWinCE211 kbWinCE212 kbWinCE300