未创建注册表项

本文关键字:注册表 创建 | 更新日期: 2023-09-27 18:02:34

我已经没有麻烦创建/删除密钥到CurrentUser,但每当我尝试LocalMachine什么都没有发生。我已经将("requestedExecutionLevel level="requireAdministrator" uiAccess="false")添加到app.manifest中。我错过什么了吗?

    private void button1_Click(object sender, EventArgs e)
    {
        RegistryKey rKey;
        rKey = Registry.LocalMachine.OpenSubKey("Software", true);
        rKey.DeleteSubKey("test", true);
        rKey.Close();            
    }
    private void button2_Click(object sender, EventArgs e)
    {
        RegistryKey rKey;
        rKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
        rKey.CreateSubKey("test");
        rKey.Close();
    }

未创建注册表项

如上所述,64位Windows上的32位应用程序出于兼容性原因在HKLM'SOFTWARE'Wow6432Node中虚拟化HKLM'SOFTWARE键。

如果您希望在HKLM'SOFTWARE中实际创建密钥,则需要将应用程序重新构建为64位。

在我看来,只要你能加载和保存键,键在的实际存储位置就不重要了。