我已经没有创建/删除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();
}
如果您正在寻求调试帮助,那么查看工作方法,而不是工作方法和不工作的描述(例如,您没有在任何地方检查'null')会有帮助。狂猜 - [64位问题](http://stackoverflow.com/q/1268715/1997232)。 – Sinatr
我会尝试看似合理的64位解决方案。但工作方法只是用CurrentUser – user6722600
取代LocalMachine,你确定密钥存在吗? – Steve