Jazz W
Jazz W

Reputation: 139

Registrykey in 64 bits OS shows 32 bit applications

string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";     

gives me the same results as

string registry_key_x64 = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";

both on a 64 bit OS. When i go in the Registry Editor and go to

"*SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall*" 

it shows me other applications then my code provides me.

For example in the Registery Editor i have "wampserver". See picture of my Registry Editor.

But when i run my code it shows different applications then i have in my Registry Editor ( it shows the 32 bit application list) Command Prompt (Running Code)

My code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Win32;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
            using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
            {
                foreach (string subkey_name in key.GetSubKeyNames())
                {
                    using (RegistryKey subkey = key.OpenSubKey(subkey_name))
                    {
                        if (subkey.GetValue("DisplayName") != null)
                        {
                            Console.WriteLine(subkey.GetValue("DisplayName"));
                        }

                    }
                }
            }

Upvotes: 0

Views: 73

Answers (1)

manuel
manuel

Reputation: 252

Most likely your application runs as 32Bit application and therefore returns the WoW nodes of the registry. Build your application as AnyCPU or 64 Bit application.

Upvotes: 1

Related Questions