Is there a way to create a registry SubKey and set it's value under HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\
in C#
I've tried
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);
but it creates the registry SubKey under HKEY_CURRENT_USER
I want to set the version of Internet Explorer used by the WPF WebBrowser Control and don't really know how to
You should check your key exists and if not create it
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);