Is it possible to determine through the WebBrowser class whether IE Enhanced Security Configuration is enabled?

Case: In a desktop application, rendering takes place in html. In the case of protection included in IE, running scripts on the page will result in an error:

System.Runtime.InteropServices.COMException (0x800700AA): The requested resource is in use. (Exception from HRESULT: 0x800700AA).

I would like to immediately understand that protection is turned on and give the user a message about the need to change the settings without dropping a heap of such errors.

  • Perhaps there is an easier way, such as getting into the registry, and is there to see this setting? - Vladislav Vitalyev

1 answer 1

If you rely on the solutions proposed here and here , you get the following verification function:

 // using Microsoft.Win32; // using System.Security.AccessControl; static bool IsIeEnhancedSecurityEnabled() { var keyNames = new [] { @"SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}", @"SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" }; foreach (var keyName in keyNames) { using (var key = Registry.LocalMachine.OpenSubKey(keyName, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.ReadKey)) { if (key != null) { var value = key.GetValue("IsInstalled") as int?; if (value == 1) { return true; } } } } return false; } 

Checked on Windows Server 2008 R2, for other versions there is no opportunity to test.