Visual Studio 2010 Setup Project 64 bit create reg

2019-02-18 09:12发布

问题:

I have a 64 bit setup project with a 64 bit windows service exe and dlls. In my installer class i create registry keys with this code:

using (typeKey = typeKey.CreateSubKey(@"SOFTWARE\Folder\Folder\Folder"))
        {
            typeKey.SetValue("Type", 0);
            typeKey.Close();
        }

But it keeps creating registry keys at SOFTWARE\WOW6432NODE\SOFTWARE\FOLDER\FOLDER\FOLDER. Btw setup copies exe and dlls under 64bit program files folder. No problem in copying folders to 64 bit folder.

Any idea?

回答1:

You are using .NET 4, use the new RegistryKey.OpenBaseKey() method and pass RegistryView.Registry64



回答2:

This happens because your custom action uses a 32-bit process. Perhaps this article will help: http://blogs.msdn.com/b/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx

Basically, you need to either make it use a 64-bit process or call a function that can write in the 64-bit registry hive.