CWebView::CWebView  
 
CWebView();

The CWebView constructor initializes the class library and validates the license key at runtime.

Remarks

If the constructor fails to validate the runtime license, subsequent methods in this class will fail. If the product is installed with an evaluation license, then the application will only function on the development system and cannot be redistributed.

The constructor calls the Initialize method to initialize the library, which dynamically loads other system libraries and allocates thread local storage. If you are using this class within another DLL, it is important that you do not create or destroy an instance of the class from within the DllMain function because it can result in deadlocks or access violation errors. You should not declare static or global instances of this class within another DLL if it is linked with the C runtime library (CRT) because it will automatically call the constructors and destructors for static and global C++ objects and has the same restrictions.

The calling thread must be in a single-threaded apartment (STA). During initialization the library calls CoInitializeEx as needed and if your process has already initialized COM as MTA (COINIT_MULTITHREADED), initialization will fail. This requirement comes directly from the Edge WebView2 control which cannot be created in an MTA COM application.

Before creating an instance of this class, applications may optionally call CWebView::RuntimeAvailable to determine if the Microsoft Edge WebView2 runtime is installed and meets the minimum required version. This can be useful during application startup to provide a clear error message or guidance to the user if the runtime is missing or out of date, rather than attempting to initialize the control and handling the failure afterward.

On modern versions of Windows, the WebView2 runtime is included as part of the operating system and is serviced through Windows Update. However, on older or unsupported versions of Windows the runtime may not be present by default and must be installed separately. In these cases, your application needs to detect the missing runtime and prompt the user to install it.

The latest WebView2 runtime version officially supported on Windows 7 and Windows 8/8.1 is version 109.0.1518.140, released January 2023. After version 109, no further updates, new features, or fixes have been provided for those operating systems. Although this library supports Windows 7 and Windows 8, these platforms are not recommended because they no longer receive security updates for the browser.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib

See Also