搜索注册表项,以在.net Core和.net框架中提供不同的输出 [英] Searching registry keys giving different outputs in .net core and .net framwork

查看:63
本文介绍了搜索注册表项,以在.net Core和.net框架中提供不同的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下位置搜索特定的注册表项时 本地计算机SOFTWARE \ Microsoft \ Windows \ CurrentVersion \使用C#卸载,>.net框架应用程序给出的结果与.Net核心应用程序中的结果不同

While searching for a particular registry key under Local machine SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall using C#, the >net framework application is giving different result than in .Net core App

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", false);

Console.WriteLine(key.GetSubKeyNames().Length);
foreach (String keyName in key.GetSubKeyNames())
{

    RegistryKey subkey = key.OpenSubKey(keyName);
    string displayName = subkey.GetValue("DisplayName") as string;
    if (displayName == null)
    {
        Console.WriteLine("NULL");
        continue;
    }
    Console.WriteLine(displayName);
    if (displayName.Contains("MyApp") == true)
    {
        Console.WriteLine("Found");
        return;
    }
}

.net框架给出了863个名称,.net核心给出了247套不同的结果.

.Net framework giving out 863 names and .net core giving 247 different set of outcome.

推荐答案

我怀疑.NET Framework应用程序是32位程序,而.NET Core应用程序在64位运行时下运行.

I suspect the .NET Framework app is 32 bit program and the .NET Core app runs under the 64 bit runtime.

如果要在.NET Core应用程序中枚举WOW64注册表,则可以按照此处的说明进行操作:

If you want to enumerate the WOW64 registry in the .NET Core app you can follow the instructions here: How to open a WOW64 registry key from a 64-bit .NET application

这篇关于搜索注册表项,以在.net Core和.net框架中提供不同的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆