Skip to content

Instantly share code, notes, and snippets.

@hediet
Created August 17, 2016 03:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hediet/8d6df553e9af447c52d5c3bbdff12ae4 to your computer and use it in GitHub Desktop.
Save hediet/8d6df553e9af447c52d5c3bbdff12ae4 to your computer and use it in GitHub Desktop.
A fix that enables IE11 for the WPF browser control.
internal static class WebBrowserIE11Fix
{
public static void SetIE11KeyforWebBrowserControl(string processPath = null)
{
if (processPath == null)
{
processPath = Process.GetCurrentProcess().ProcessName + ".exe";
}
RegistryKey Regkey = null;
try
{
//Environment.Is64BitOperatingSystem
Regkey = Registry.CurrentUser.OpenSubKey(false
? @"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION"
: @"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
if (Regkey == null)
{
Debug.WriteLine("Could not open registry key to set IE11 for browser control");
return;
}
// see https://msdn.microsoft.com/en-us/library/ee330730(VS.85).aspx#browser_emulation
var emulationCode = (int)Regkey.GetValue(processPath);
const int ie11Code = 11000;
if (emulationCode != ie11Code)
Debug.WriteLine("Key already set to a different value ({0}), overwriting.", emulationCode);
Regkey.SetValue(processPath, ie11Code, RegistryValueKind.DWord);
}
finally
{
Regkey?.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment