0

Based on other information I found I came up with the following:

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        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();
        }
    }
}

But, it is provided the version number for the legacy Microsoft Edge and not the newer Microsoft Edge Chromium.

What changes are needed to this code?

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • 1
    Did you check this [question](https://stackoverflow.com/questions/62521506/how-can-i-check-the-version-of-the-new-microsoft-edge-chromium-from-inside-my-c)? – Pavel Anikhouski Nov 01 '20 at 12:01
  • Hi @PavelAnikhouski. Thanks for the hint. I was able to take that screenshot of the registry key and convert it into some code. Now the version is correct. I support my only concern now is can the presence of this key be sufficient enough for confirming that Microsoft Edge Chromium **is** installed? – Andrew Truckle Nov 01 '20 at 12:10
  • It think, only MS devs can confirm it:) However, you can close your question as duplicate and raise a comment in linked question – Pavel Anikhouski Nov 01 '20 at 12:39

1 Answers1

0

Based on the answer in the comments I have a working C# example:

using Microsoft.Win32;
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string EdgeVersion = string.Empty;

            RegistryKey reg = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Edge\BLBeacon");
            if(reg != null)
            {
                EdgeVersion = reg.GetValue("version").ToString();
            }

            Console.WriteLine("Edge Version(empty means not found): {0}", EdgeVersion);
            Console.ReadLine();
        }
    }
}
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164