3

I am planning to add functionality to a small application developed in VB6 which will check the pre-requisites for a WPF application that uses WebView2 control. This small application will run first and determine if the "Microsoft Edge WebView2 Runtime" or "Microsoft Edge Insider Channels" is installed? If it founds one of these options then allows to run the WPF application otherwise it will show an error to install the pre-requisite.

My requirement is to keep the VB6 app because this app is already checking the different versions of the .NET framework.

Please help me, how to achieve this?

Thanks.

Imran Yaseen
  • 543
  • 1
  • 5
  • 20
  • 1
    You can check whether the application is installed in the registry. Unfortunately, I do not have a VB example of this situation, if it was C#, I could share it with you. On the C# side, checking from the Microsoft.Win32.Registry class may show you the way to go. – Ozgur Saklanmaz Apr 13 '22 at 11:56
  • @OzgurSaklanmaz yes that works but i was able to check only runtime. I used this link https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution. But how can I check the Inisder channel is installed through registry? What exactly the entry is for insider channel canary? – Imran Yaseen Apr 13 '22 at 12:42
  • I see this link https://github.com/MicrosoftEdge/WebView2Feedback/issues/421 very useful. It also mentioned the registry entry for canary. – Imran Yaseen Apr 13 '22 at 12:48
  • 1
    As in the second post you mentioned, you need to check this field to see if it is installed. I tried it in C#. It shows "Microsoft Edge WebView2 Runtime" installed. SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall – Ozgur Saklanmaz Apr 13 '22 at 12:53
  • 1
    I can share the C# code if you want. Maybe you can convert it to VB. – Ozgur Saklanmaz Apr 13 '22 at 12:54

1 Answers1

2

Apologies I don't know what it looks like in VB, but you should be able to use the static methods CoreWebView2Environment.GetAvailableBrowserVersionString and CoreWebView2Environment.CompareBrowserVersions. GetAvailableBrowserVersionString will tell you which WebView2 Runtime version would be used if a WebView2 were created and you can use CompareBrowserVersions to check if the version you get from GetAvailableBrowserVersionString is higher than your minimum required version.

string availableVersion = null;
try
{
    availableVersion = CoreWebView2Environment.GetAvailableBrowserVersionString();
}
catch (WebView2RuntimeNotFoundException)
{
}

if (availableVersion != null &&
    CoreWebView2Environment.CompareBrowserVersions(availableVersion, "100.0.0.0") >= 0)
{
    System.Console.WriteLine("Minimum version found");
}
else
{
    System.Console.WriteLine("Minimum version not found.");
}
David Risney
  • 3,886
  • 15
  • 16