有没有办法创建注册表SubKey并在C#中HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\
下设置它的值
我已经尝试了
using System.Security.Permissions;
using Microsoft.Win32;
...
Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\MyApp.exe", true);
Microsoft.Win32.Registry.CurrentUser.SetValue(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\MyApp.exe", 11001);
但它在HKEY_CURRENT_USER
我想设置WPF WebBrowser控件使用的Internet Explorer版本,并且不知道如何
答案 0 :(得分:0)
你应该检查你的密钥是否存在,如果没有创建它
var localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32);
var key = localMachine.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
var subKey = key.OpenSubKey("MyApp.exe", true);
if (subKey == null)
{
subKey = key.CreateSubKey("MyApp.exe");
}
subKey.SetValue("MyApp.exe", 10001);