Note the problem of modified version of client WebBrowser control

Time:2020-11-1

The second description of a record kept on the local computer is from the Internet. If you forget where you read it, you have not indicated the source. I understand.

1. The underlying call of WinForm built-in browser control is the same as that of system IE browser.

2. IE8 has made great changes to the rendering engine, adding a new standard mode. When the user machine is upgraded to IE8, the WebBrowser control will also be upgraded to IE8’s rendering engine. In order to ensure that the application software using the WebBrowser control can work as before, the WebBrowser control in IE8 environment uses IE7 rendering mode (i.e. compatible view mode in IE8) by default, and the same as above in IE9, ie10 and ie11. Through the system registrymodifyThis control can be modified to standard mode rendering (tested by native ie11). After modification, the client needs corresponding permissions to read and write the registry.

3. Requirements for building chrome kernel browser control CefSharp The project can support chromium kernel control, but the project needs the support of. Net 4.5.2 framework at least. After checking the historical version, the project’s large version No. 49 is the last version to support net4.0. The version gap is too large and is not recommended.

4. The complete process name should be used when adding the registry key, such as: chrome.exe 。 If the chrome setting is invalid.

5、Registry location record

Record the path where the WebBrowser control uses the IE render version:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION;

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION;

Record the location of the current system ie version:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet ExplorerVersionby

The current system comes with IE version, if it existssvcVersion, this is the upgraded version of IE.

6. When adding the registry, the IE version codes are as follows:

switch (IEVersion)
            {
                case 7:  //7000 (0x1B58)     IE7
                    version = 0x1B58;
                    break;
                case 8:  // 8000 (0x1F40)     IE8
                    version = 0x1F40;
                    break;
                case 9:  //9000 (0×2328)    IE9
                    version = 0x2328;
                    break;
                case 10: //10000(0×2710)    IE10
                    version = 0x2710;
                    break;
                case 11: //11000(0×2af8)    IE11
                    version =0x2af8;
                    break;
                default :
                    version = 0x2328;
                    break;
            }

7、

/*Creation time:
 *Creation purpose: modify the fixed registry key to make the WebBrowser control use the standard rendering mode of native ie to render the linked content,
 *Instead of the default compatibility mode.
 *When this file gets the IE version error, the registry key will be set to the corresponding value of IE9 by default, because IE9 is the version of win7.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.Windows.Forms;
using System.Diagnostics;

namespace XXXXXX
{
    class SetIEVersionByRegedit
    {
        //private bool is64BitSystem = false;

        const string DEFAULT_IE_VERSION = "9.0";

        const string COMMON_PATH_FRONT = @"SOFTWARE";

        const string DIFF_BETWEEN_32_AND_64 = @"\Wow6432Node";

        const string COMMON_PATH_BEHIND = @"\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";

        //Discard the following contents and write both registry entries
        //private int GetBitOperatingSystem ()
        //{            
        //    return Environment.Is64BitOperatingSystem ? 64 : 32;
        //}

        //private string GetSettingPath ()
        //{
        //    int systemBit = GetBitOperatingSystem();
        //    if (systemBit == 32)
        //    {
        //        return new StringBuilder().Append(COMMON_PATH_FRONT).
        //    }
        //}

        public void SetRegistry()
        {
            int IEVersion = GetIEVersion();
            string itemName = GetItemNameNeedCreat();
            uint itemValue = GetItemValueNeedCreat(IEVersion);
            string path32Key = COMMON_PATH_FRONT + COMMON_PATH_BEHIND;
            string path64Key = COMMON_PATH_FRONT + DIFF_BETWEEN_32_AND_64 + COMMON_PATH_BEHIND;
            WriteToRegistry(path32Key, itemName, itemValue);
            WriteToRegistry(path64Key, itemName, itemValue);
        }

        #Region gets ie version
        private int GetIEVersion ()
        {
            string version = "9";
            try
            {
                version = GetIEVersionByWebControl();
            }
            catch
            {
                version = GetIEVersionByRegistry();
            }            
            return Convert.ToInt32(version);
        }


        /// 
        ///Get the IE version through the registry and return 9 by default
        /// 
        /// 
        private string GetIEVersionByRegistry ()
        {
            String version = "9.0"; // win7 comes with
            try
            {
                RegistryKey ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer");
                if(ieKey == null)
                {
                    return version;
                }
                version = ieKey.GetValue("Version").ToString();
                //This item exists for native ie upgrade
                if (ieKey.GetValue("svcVersion") != null)
                {
                    version = ieKey.GetValue("svcVersion").ToString();
                }
            }
            catch { } 
            return version.Substring(0, version.IndexOf("."));                                 
        }

        private string GetIEVersionByWebControl ()
        {
            string version = (new WebBrowser()).Version.Major.ToString();
            return version;
        }
        #endregion
        //
        private uint GetItemValueNeedCreat (int IEVersion)
        {
            uint version = 0x2328;
            switch (IEVersion)
            {
                case 7:  //7000 (0x1B58)     IE7
                    version = 0x1B58;
                    break;
                case 8:  // 8000 (0x1F40)     IE8
                    version = 0x1F40;
                    break;
                case 9:  //9000 (0×2328)    IE9
                    version = 0x2328;
                    break;
                case 10: //10000(0×2710)    IE10
                    version = 0x2710;
                    break;
                case 11: //11000(0×2af8)    IE11
                    version =0x2af8;
                    break;
                default :
                    version = 0x2328;
                    break;
            }
            return version;
        }

        private string GetItemNameNeedCreat ()
        {
            string keyName = "XXXXX.exe";
            try
            {
                keyName = GetCurrentProessName();
            }
            catch { }

            return keyName;
        }
        
        private string GetCurrentProessName ()
        {
            var process = Process.GetCurrentProcess();
            string ProcessModuleName = Process.GetCurrentProcess().MainModule.ModuleName;
            return ProcessModuleName;
        }      

        private void WriteToRegistry(string keyName,string itemName,object itemValue)
        {
            try
            {
                if (IsExistSetting( keyName, itemName, itemValue)) { return; }
                RegistryKey root = Registry.LocalMachine;
                RegistryKey key = root.OpenSubKey(keyName, true);
                key.SetValue(itemName, itemValue, RegistryValueKind.DWord);
            }
            Catch (exception Ex) // if there is an error in setting, use the client computer to set it
            {
            }            
        }

        private bool IsExistSetting (string keyName, string itemName, object itemValue)
        {
            RegistryKey root = Registry.LocalMachine;
            RegistryKey key = root.OpenSubKey(keyName, true);
            if(key == null)
            {
                return false;
            }
            return key.GetValue(itemName,string.Empty).ToString() == itemValue.ToString();
        }      
    }
}

Recommended Today

Api: tiktok: user video list

Tiktok tiktok, tiktok, tiktok, Api, Api, jitter, voice, bullet screen comments, jitter, jitter, and jitter. Tiktok tiktok tiktok data, jitter data acquisition, live broadcast of shaking sound Titodata: professional short video data acquisition and processing platform. For more information, please contact:TiToData Massive data collection Collect 500 million pieces of data for customers every day Tiktok […]