Read a Registry Key

前端 未结 5 2125
傲寒
傲寒 2020-12-03 01:44

I have a web application which is importing DLLs from the bin folder.

const string dllpath = \"Utility.dll\";

    [DllImport(dllpath)]

Now

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 01:50

    None of these answers worked for me. This is what I used:

    static void Main()
    {
        const string dotNetFourPath = "Software\\Microsoft";//note backslash
        using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(dotNetFourPath))
        {
            Console.WriteLine(registryKey.SubKeyCount);//registry is not null
            foreach (var VARIABLE in registryKey.GetSubKeyNames())
            {
                Console.WriteLine(VARIABLE);//here I can see I have many keys
                //no need to switch to x64 as suggested on other posts
            }
        }
    }
    

提交回复
热议问题