Hi,
EdgeLoaded detects Edge Chromium which is half of the job but is there any way of detecting if the Microsoft Edge WebView2 Runtime is installed?
Thanks,
Ken
Hi,
EdgeLoaded detects Edge Chromium which is half of the job but is there any way of detecting if the Microsoft Edge WebView2 Runtime is installed?
Thanks,
Ken
I've worked out that I can use the code below but I don't know if that will continue to work in the future!
function CheckIfWebView2Installed:Boolean;
var
Reg:TRegistry;
S:String;
begin
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Result:=Reg.KeyExists('SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}\');
except
end;
Reg.Free;
end;
Hi,
You can check if GetAvailableCoreWebView2BrowserVersionString is assigned, this call is being used to retrieve the version number, so when the DLL is loaded and this method is mapped, it should return a version number.
Thanks Pieter. I see the EdgeVersion is the same as the registry detailed above pv value name. Out of interest are you using the same mechanism in your DLL?
No, we are not using a registry check, we are using the following code to detect the version number.
v := '';
if Assigned(GetAvailableCoreWebView2BrowserVersionString) then
begin
GetAvailableCoreWebView2BrowserVersionString(nil, @v);
EdgeVersion := v;
end;
Hi Pieter. Could you provide a bit more info on how to use this code you use to find the WebView2 version numbers:
v := '';
if Assigned(GetAvailableCoreWebView2BrowserVersionString) then
begin
GetAvailableCoreWebView2BrowserVersionString(nil, @v);
EdgeVersion := v;
end;
Thanks.
Here is a complete sample:
unit Unit14;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm14 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form14: TForm14;
implementation
{$R *.dfm}
uses
VCL.TMSFNCUtils;
var
GetAvailableCoreWebView2BrowserVersionString: function(browserExecutableFolder: PWideChar; versioninfo: PPWideChar): HRESULT; stdcall;
procedure TForm14.Button1Click(Sender: TObject);
var
v: PWideChar;
h: HWND;
begin
h := LoadLibrary('WebView2Loader_x86.dll');
if (h = 0) then
Exit;
GetAvailableCoreWebView2BrowserVersionString := GetProcAddress(h, 'GetAvailableCoreWebView2BrowserVersionString');
v := '';
if Assigned(GetAvailableCoreWebView2BrowserVersionString) then
begin
GetAvailableCoreWebView2BrowserVersionString(nil, @v);
TTMSFNCUtils.Log(v);
end;
end;
end.
Thanks Pieter, just what I needed.