64位OS中的RegistryKey显示了32位应用


string registry_key = @"SOFTWAREMicrosoftWindowsCurrentVersionUninstall";     

给我与

相同的结果
string registry_key_x64 = @"SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall";

两者在64位OS上。当我进入注册表编辑时,请转到

"*SOFTWAREMicrosoftWindowsCurrentVersionUninstall*" 

它向我展示了其他应用程序,然后我的代码为我提供了。

例如,在寄存器编辑器中,我有" Wampserver"。请参阅我的注册表编辑的图片。

但是,当我运行代码时,它显示了不同的应用程序,然后我在注册表编辑器(显示32位应用程序列表(命令提示(运行代码(

我的代码:

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 = @"SOFTWAREMicrosoftWindowsCurrentVersionUninstall";
            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"));
                        }
                    }
                }
            }

您的应用程序很可能以32位应用程序运行,因此返回注册表的WOW节点。将您的应用程序构建为Anycpu或64位应用程序。

最新更新