基本上我需要创建一个路径:
HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Internet Settings \ ZoneMap \ Domains \ myDomain \ Subdomain
创建一个名为*(星号)的DWORD,其值为2 我在控制台运行时遇到错误,它没有做任何事情。
我认为这是因为myDomain \ Subdomain不存在。这是我的代码:
RegistryKey myKey = Registry.CurrentUser.OpenSubKey("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\google.com\\sites", true);
myKey.SetValue("*", "2", RegistryValueKind.DWord);
myKey.Close();
答案 0 :(得分:0)
CurrentUser返回一个RegistryKey。你想在那上面调用CreateSubKey。像这样,我想:
RegistryKey myKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\google.com\\sites",true);
答案 1 :(得分:0)
我明白了!我只是简单地过度复杂了我之前尝试过的东西,解决方案如下:
RegistryKey myKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\google.com\\sites");
myKey.SetValue("*", "2", RegistryValueKind.DWord);
myKey.Close();