How to install different registry entries based on the Operating System (32/64-bit)?

When distributing a mixed 32/64-bit package, the application installed by the package may use a 32-bit or 64-bit version of the same registry key. In this How-To, the package must create a 32-bit version or a 64-bit version of the HKEY_LOCAL_MACHINE\Software\MyKey registry key.

The tree control in the Registry page does not support duplicate entries, but the "Registry" table inside the MSI supports them. Therefore, a solution is to create a key which uses a property in its name. Here are the steps for the HKEY_LOCAL_MACHINE\Software\MyKey registry key (you can adapt the example to your custom registry keys):

  1. Go to the "Registry" page and create the HKEY_LOCAL_MACHINE\Software\MyKey registry key
  2. Add your 32-bit registry values in it
  3. Go to the Organization page and select the feature which contains the registry values
  4. Press SHIFT+F4 on your keyboard to see the contents of the feature
  5. Select the components of the 32-bit registry values, right-click one of them and select the "Properties" menu
  6. In the "Edit Component Properties" dialog set the Condition field to NOT VersionNT64
  7. Go to the Install Parameters page and create a custom property (for example MY_REG_KEY)
  8. Set its value to the name of your custom registry key (MyKey)
  9. Go to the "Registry" page and select the parent key of your custom registry key (HKEY_LOCAL_MACHINE\Software)
  10. Create under it a new registry key
  11. Rename it to the custom property you created ([MY_REG_KEY])
  12. Now you should have these keys: HKEY_LOCAL_MACHINE\Software\MyKey and HKEY_LOCAL_MACHINE\Software\[MY_REG_KEY]
  13. Add the 64-bit registry values in the [MY_REG_KEY] key
  14. Go to the "Organization" page and select the feature which contains them
  15. Press SHIFT+F4 on your keyboard and select the components of the 64-bit registry values
  16. Right-click one of them and select the "Properties" menu
  17. In the "Edit Component Properties" dialog set the Condition field to VersionNT64
  18. Tick the option 64-bit Component

If the 32-bit values are in the same feature as the 64-bit values, the components of the values with the same name will be different. For example, if you add the "MyValue" registry value in one key and then add it in another key, the components will be named:

  • MyValue for the first key
  • MyValue_1 for the second key

If you use this approach, the package will determine the type of the target system (32/64-bit) by using the "VersionNT64" property. Also, it will install only the components which correspond to the system type.