-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWebBrowserExtensions.cs
54 lines (49 loc) · 1.56 KB
/
WebBrowserExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Windows.Forms;
using Microsoft.Win32;
namespace Leaf.Forms
{
public static class WebBrowserExtensions
{
/// <summary>
/// Activate latest engine of IE WebView component.
/// </summary>
/// <param name="wb">WebBrowser</param>
public static bool Modernize(this WebBrowser wb)
{
int browserVer = wb.Version.Major;
int regVal;
// Set the appropriate Internet Explorer version
if (browserVer >= 12) // Edge
regVal = 12001;
else switch (browserVer)
{
case 11:
regVal = 11001;
break;
case 10:
regVal = 10001;
break;
case 9:
regVal = 9999;
break;
case 8:
regVal = 8888;
break;
default:
regVal = 7000;
break;
}
// Set the actual key
using (var key = Registry.CurrentUser.OpenSubKey(
@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true))
{
if (key == null)
return false;
// Set newest IE Version
key.SetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe", regVal,
RegistryValueKind.DWord);
}
return true;
}
}
}