Created
August 17, 2016 03:42
-
-
Save hediet/8d6df553e9af447c52d5c3bbdff12ae4 to your computer and use it in GitHub Desktop.
A fix that enables IE11 for the WPF browser control.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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