FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour TWebView2 - Detectar si está instalado en el sistema
Posts: 728
Joined: Fri Oct 07, 2005 07:38 AM
TWebView2 - Detectar si está instalado en el sistema
Posted: Fri Oct 25, 2024 06:03 PM

Hola amigos, estoy "jugueteando" con TWebView2.

¿Existe algún modo de detectar si el "WebView2 Runtime" está instalado en el sistema?

Gracias,

Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: TWebView2 - Detectar si está instalado en el sistema
Posted: Fri Oct 25, 2024 06:06 PM
Hola Angel buenas tardes como estas?
Code (fw): Select all Collapse
    lSisas := IsWebViewAvailable()
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 728
Joined: Fri Oct 07, 2005 07:38 AM
Re: TWebView2 - Detectar si está instalado en el sistema
Posted: Fri Oct 25, 2024 07:48 PM

Hola Leandro, gracias. Pero esa función solo detecta si webview.dll puede cargarse.

En el caso de webview2 no es necesaria.

Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
Posts: 34
Joined: Tue Mar 20, 2012 11:06 PM
Re: TWebView2 - Detectar si está instalado en el sistema
Posted: Sun Oct 27, 2024 01:50 AM
AngelSalom wrote:Hola Leandro, gracias. Pero esa función solo detecta si webview.dll puede cargarse.
En el caso de webview2 no es necesaria.
Hola :
te suguiero leas https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution?tabs=win32cpp#detect-if-a-webview2-runtime-is-already-installed
Slds
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TWebView2 - Detectar si está instalado en el sistema
Posted: Sun Oct 27, 2024 06:54 AM
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

    MsgInfo( IsWebView2Available() )

return nil

function IsWebView2Available()

return ! Empty( TWebView2():New():hWebView )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 728
Joined: Fri Oct 07, 2005 07:38 AM
Re: TWebView2 - Detectar si está instalado en el sistema
Posted: Sun Oct 27, 2024 08:23 AM

Gracias Antonio, simple y efectivo.

Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
Posts: 728
Joined: Fri Oct 07, 2005 07:38 AM
Re: TWebView2 - Detectar si está instalado en el sistema
Posted: Mon Oct 28, 2024 03:55 PM
Danielmaximiliano wrote:
Hola Leandro, gracias. Pero esa función solo detecta si webview.dll puede cargarse.
En el caso de webview2 no es necesaria.
Hola :
te suguiero leas https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution?tabs=win32cpp#detect-if-a-webview2-runtime-is-already-installed
Slds
Respecto a esta aproximación, en Windows 7 ( sí aún me quedan clientes usándolo ), da mejor resultado que la propuesta por Antonio, ya que aquella arroja un error de protección si el componente no está instalado.
Lo dicho, basándome en el enlace y siguiendo las instrucciones de Microsoft, se consulta el valor adecuado en diferentes puntos del registro.
Code (fw): Select all Collapse
Static Function IsWebView2Available()

    // Comprueba en RegEdit si está instalado WebView2
    // https://learn.microsoft.com/es-es/microsoft-edge/webview2/concepts/distribution?tabs=dotnetcsharp#detect-if-a-webview2-runtime-is-already-installed

    #define  HKEY_CURRENT_USER       2147483649        // 0x80000001
    #define  HKEY_LOCAL_MACHINE      2147483650        // 0x80000002

    Local oReg AS Object := nil
    Local cPv AS String := ''
    
    oReg := TReg32():New( HKEY_LOCAL_MACHINE, 'SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', .F. )
    cPv := oReg:Get( 'pv' )

    if Empty( cPv )

        oReg := TReg32():New( HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', .f. )
        cPv := oReg:Get( 'pv' )

    endif

    if Empty( cPv )

        oReg := TReg32():New( HKEY_CURRENT_USER, 'Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', .f. )
        cPv := oReg:Get( 'pv' )

    endif
    
return ( .Not. Empty( cPv ) )
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TWebView2 - Detectar si está instalado en el sistema
Posted: Mon Oct 28, 2024 05:13 PM

Muy bien!

No probé la función en Windows 7...

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion