Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect if Microsoft Edge is installed?

I'm writing a windows form application (c#) and I need to detect whether the user have "Microsoft-Edge" installed in his/her machine or not.

I'm currently using this registry location:

[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages\Microsoft.MicrosoftEdge_20.10240.16384.0_neutral__8wekyb3d8bbwe]
"Path"="C:\\Windows\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"

With a regex after the "Microsoft.MicrosoftEdge". If the "path" exist then I know edge is installed.

Is there a better way to detect edge? would it be better if I detect that I'm running on Windows 10 and by default Win10 come with edge? What is the best way for that?

like image 924
Aviram Fireberger Avatar asked Nov 08 '15 13:11

Aviram Fireberger


1 Answers

In case you want to have a small program getting that version number:

static void Main(string[] args)
    {
        string EdgeVersion = string.Empty;
        //open the registry and parse through the keys until you find Microsoft.MicrosoftEdge
        RegistryKey reg = Registry.ClassesRoot.OpenSubKey(@"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages");
        if (reg != null)
        {
            foreach (string subkey in reg.GetSubKeyNames())
            {
                if (subkey.StartsWith("Microsoft.MicrosoftEdge"))
                {
                    //RegEx: (Microsoft.MicrosoftEdge_)(\d +\.\d +\.\d +\.\d +)(_neutral__8wekyb3d8bbwe])
                    Match rxEdgeVersion = null;
                    rxEdgeVersion = Regex.Match(subkey, @"(Microsoft.MicrosoftEdge_)(?<version>\d+\.\d+\.\d+\.\d+)(_neutral__8wekyb3d8bbwe)");
                    //just after that value, you need to use RegEx to find the version number of the value in the registry
                    if ( rxEdgeVersion.Success )
                        EdgeVersion = rxEdgeVersion.Groups["version"].Value;
                }
            }
        }

        Console.WriteLine("Edge Version(empty means not found): {0}", EdgeVersion);
        Console.ReadLine();
    }

Thank you for the registry link for finding the version number.

like image 94
R Mimick Avatar answered Oct 19 '22 20:10

R Mimick