I have an application in C#. When installing the msi, the user is requested to input some values and these are entered in registry under HKEY_LOCAL_MACHINE\SOFTWARE\MyFolder. When running the application, the value is read from the registry location and the application uses these values for processing. This works fine on Windows XP.
Now I have recently moved to Windows 7 64 bits. When installing the application on Win 7, the registry entries are created at HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MyFolder. The problem I am having is that I have hard coded my application to read values from HKEY_LOCAL_MACHINE\SOFTWARE\MyFolder. How do I change this to make my application compatible with Win XP, Win 7 and Win 8?

Your help will be greatly appreciated.

You need to set your application to target CPU Type x86.

Thanks for your reply but the target platform is already set to x86. How do I read the values from registry? As I said I have hard coded the application to read from HKEY_LOCAL_MACHINE\SOFTWARE\MyFolder. How to make it determine the location automatically?

Maybe I misunderstood your reply. If you meant "Change Platform in Configuration Manager to x86 (and not Any CPU)", then this solved my problem!

A better question is why are you using the registry for your application in the first place? That's no longer best practice for arbitrary configuration.

Yes, that is what I meant and I agree that the registry isn't the best practice anymore.

The only exception in my opinion is for services.
You may not want to give them access to the local file system and so storing their modifiable configuration in the registry makes more sense.

What is wrong with storing those values into resources or in settings? That way these values always are part of the app itself.

Settings are stored on the file system. Whilst under normal operation that's perfectly fine, if you're running under the context of say NETWORK SERVICE then you won't have, or want to give, access to the file system. Registry makes sense at this point.

Using resources is a bad idea in general because you can't change the values entered.

commented: Thanks for the clarification! +14