This repository has been archived by the owner on Jul 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the latest version of IE in WebBrowser control
- Loading branch information
Showing
6 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
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
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
74 changes: 74 additions & 0 deletions
74
Plugins/DNTProfiler.ApplicationAnnouncements/Core/UseLatestVersionOfIE.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using Microsoft.Win32; | ||
using System.Windows.Forms; | ||
using DNTProfiler.Common.Logger; | ||
using DNTProfiler.Common.Mvvm; | ||
|
||
namespace DNTProfiler.ApplicationAnnouncements.Core | ||
{ | ||
public static class UseLatestVersionOfIE | ||
{ | ||
/// <summary> | ||
/// Use the latest version of IE in WebBrowser control | ||
/// </summary> | ||
public static void SetWebBrowserVersion() | ||
{ | ||
RegistryKey regkey = null; | ||
try | ||
{ | ||
regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", writable: true); | ||
if (regkey == null) | ||
{ | ||
return; | ||
} | ||
|
||
var regVal = getInstalledIEVersion(); | ||
var appName = string.Format("{0}.exe", Process.GetCurrentProcess().ProcessName); | ||
regkey.SetValue(appName, regVal, RegistryValueKind.DWord); | ||
} | ||
catch (Exception ex) | ||
{ | ||
new ExceptionLogger().LogExceptionToFile(ex, AppMessenger.LogFile); | ||
AppMessenger.Messenger.NotifyColleagues("ShowException", ex); | ||
} | ||
finally | ||
{ | ||
if (regkey != null) | ||
{ | ||
regkey.Close(); | ||
} | ||
} | ||
} | ||
|
||
private static int getInstalledIEVersion() | ||
{ | ||
int browserVer; | ||
using (var wb = new WebBrowser()) | ||
{ | ||
browserVer = wb.Version.Major; | ||
} | ||
|
||
int regVal; | ||
if (browserVer >= 11) | ||
regVal = 11001; | ||
else | ||
switch (browserVer) | ||
{ | ||
case 10: | ||
regVal = 10001; | ||
break; | ||
case 9: | ||
regVal = 9999; | ||
break; | ||
case 8: | ||
regVal = 8888; | ||
break; | ||
default: | ||
regVal = 7000; | ||
break; | ||
} | ||
return regVal; | ||
} | ||
} | ||
} |
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
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
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