Searching registry keys giving different outputs in .net core and .net framwork

做~自己de王妃 提交于 2020-07-10 09:37:19

问题


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 framework giving out 863 names and .net core giving 247 different set of outcome.


回答1:


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

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



来源:https://stackoverflow.com/questions/58649651/searching-registry-keys-giving-different-outputs-in-net-core-and-net-framwork

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!