基本上我需要创建一条通往:
的路径hkey_current_user software Microsoft Windows currentversion Internet设置 ZoneMap domains 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();
currentuser返回注册表。您想对此致电CreateSubkey。我认为这样:
RegistryKey myKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\google.com\sites",true);
我弄清楚了!我只是简单地复杂了我早些时候尝试过的东西,解决方案如下:
RegistryKey myKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\google.com\sites");
myKey.SetValue("*", "2", RegistryValueKind.DWord);
myKey.Close();