C# 64位操作系统中的Registrykey显示32位应用程序
给我的结果和C# 64位操作系统中的Registrykey显示32位应用程序,c#,windows,visual-studio,registry,registrykey,C#,Windows,Visual Studio,Registry,Registrykey,给我的结果和 string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; 两者都在64位操作系统上。当我进入注册表编辑器并转到 string registry_key_x64 = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"; 它向我展示了其他的应用程序,然后我的代码提供给我 例如,在注册表编辑器中,
string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
两者都在64位操作系统上。当我进入注册表编辑器并转到
string registry_key_x64 = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
它向我展示了其他的应用程序,然后我的代码提供给我
例如,在注册表编辑器中,我有“wampserver”
但是,当我运行代码时,它会显示不同的应用程序,而我的注册表编辑器(它会显示32位应用程序列表)
我的代码:
"*SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall*"
您的应用程序很可能作为32位应用程序运行,因此返回注册表的WoW节点。将您的应用程序构建为AnyCPU或64位应用程序。请参阅我在AnyCPU上运行的,但我将其更改为x64,现在它可以工作了。谢谢!
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"));
}
}
}
}