Search code examples
c#google-mapswindows-7windows-8webbrowser-control

C# version of web browser warning when using google map - Windows 7 and Internet Explorer 8


I'm using VS 2013 and C# web browser control but when I run my .exe file on Windows 8 and older (e.g. Windows 7, with Internet Explorer 8 installed) then open https://maps.google.com the page say "Your Browser is Old Please Update it".

I have changed the Registry setting with three method but not working.

The first code and link of it:

Link: Use latest version of Internet Explorer in the webbrowser control

   private void SetIE11KeyforWebBrowserControl()
  {
        var appName = Process.GetCurrentProcess().ProcessName + ".exe";
        RegistryKey Regkey = null;
        try
        {
            // For 64 bit machine
            if (Environment.Is64BitOperatingSystem)
                Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@  "SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EM  ULATION", true);
            else  //For 32 bit machine
                Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@  "SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EM  ULATION", true);


            // If the path is not correct or
            // if the user haven't priviledges to access the registry
            if (Regkey == null)
            {
                if (Environment.Is64BitOperatingSystem)
                    Regkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey  (@"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EM  ULATION");
                else  //For 32 bit machine
                    Regkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey  (@"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EM  ULATION");
            }


            string FindAppkey = Convert.ToString(Regkey.GetValue(appName));


            // Check if key is already present
            if (FindAppkey == "11000")
            {
                Regkey.Close();
                //MessageBox.Show("Application set IE Key value");
                return;
            }
            else
            {
                Regkey.SetValue(appName, unchecked((int)0x2AF8), RegistryValueKind.DWord);
            }


            // Check for the key after adding
            FindAppkey = Convert.ToString(Regkey.GetValue(appName));


            if (FindAppkey != "11000")
                throw new Exception("Can not set IE key for web browser");
            else
            {
                Regkey.Close();
                //MessageBox.Show("Application set IE Key value");
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Application Settings Failed\n" + ex.Message);
        }
        finally
        {
            // Close the Registry
            if (Regkey != null)
                Regkey.Close();
        }

The second code:

public class Helper
{
    public static void SetBrowserEmulation(
        string programName, IE browserVersion)
    {
        if (string.IsNullOrEmpty(programName))
        {
            programName = AppDomain.CurrentDomain.FriendlyName;
            RegistryKey regKey = Registry.CurrentUser.OpenSubKey(
                "Software\\Microsoft\\Internet Explorer\\Main" +
                "\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
            if (regKey != null)
            {
                try
                {
                    regKey.SetValue(programName, browserVersion,
                        RegistryValueKind.DWord);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error writing to the registry", ex);
                }
            }
            else
            {
                try
                {
                    regKey = Registry.CurrentUser.OpenSubKey("Software" +
                        "\\Microsoft\\Internet Explorer\\Main" +
                        "\\FeatureControl", true);
                    regKey.CreateSubKey("FEATURE_BROWSER_EMULATION");
                    regKey.SetValue(programName, browserVersion,
                        RegistryValueKind.DWord);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error accessing the registry", ex);
                }
            }
        }
    }
}


public enum IE
{
    IE7 = 7000,
    IE8 = 8000,
    IE8StandardsMode = 8888,
    IE9 = 9000,
    IE9StandardsMode = 9999,
    IE10 = 10000,
    IE10StandardsMode = 10001
}

The Third and link of it: Link: How can I get the WebBrowser control to show modern contents?

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

"YourApplicationFileName.exe"=dword:00002af9
"YourApplicationFileName.vshost.exe"=dword:00002af9

UPDATE 1:

I'm using default C# Web browser control (IE base) and http://whatsmybrowser.org says: Your Browser is "Internet Explorer 8 on Windows 7"

UPDATE 2:

When I installed IE 11 on Windows 7, My .exe file Worked properly but I want to change setting with code not with install IE11.


Solution

  • When reading the link you provided, the key thing to understand is that it doesn't provide you the latest version of IE (i.e. IE 11) - it provides you the latest version of IE installed on your machine.

    Your machine has IE 8 installed. Since the C# web browser control uses the same version of IE as your machine has installed, your C# app is thus using IE 8.

    Unfortunately, Google Maps no longer supports IE 8.

    As such, you have three sets of options:

    1. Upgrade IE (e.g. to IE 11) on the machine.
    2. Upgrade OS on the machine (e.g. to Windows 10) - since that will automatically upgrade IE for you.
    3. Use a control (other than web browser control) that uses something other than IE for rendering. I am not aware of any good quality options for that.