共用方式為


interface ICoreWebView2EnvironmentOptions7

Note

This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.

interface ICoreWebView2EnvironmentOptions7
  : public IUnknown

Additional options used to create the WebView2 Environment that support specifying the ReleaseChannels and ChannelSearchKind.

Summary

Members Descriptions
get_ChannelSearchKind Gets the ChannelSearchKind property.
get_ReleaseChannels Gets the ReleaseChannels property.
put_ChannelSearchKind The ChannelSearchKind property is COREWEBVIEW2_CHANNEL_SEARCH_KIND_MOST_STABLE by default; environment creation searches for a release channel on the machine from most to least stable using the first channel found.
put_ReleaseChannels Sets the ReleaseChannels, which is a mask of one or more COREWEBVIEW2_RELEASE_CHANNELS indicating which channels environment creation should search for.

Applies to

Product Introduced
WebView2 Win32 1.0.2478.35
WebView2 Win32 Prerelease 1.0.2470

Members

get_ChannelSearchKind

Gets the ChannelSearchKind property.

public HRESULT get_ChannelSearchKind(COREWEBVIEW2_CHANNEL_SEARCH_KIND * value)

get_ReleaseChannels

Gets the ReleaseChannels property.

public HRESULT get_ReleaseChannels(COREWEBVIEW2_RELEASE_CHANNELS * value)

put_ChannelSearchKind

The ChannelSearchKind property is COREWEBVIEW2_CHANNEL_SEARCH_KIND_MOST_STABLE by default; environment creation searches for a release channel on the machine from most to least stable using the first channel found.

public HRESULT put_ChannelSearchKind(COREWEBVIEW2_CHANNEL_SEARCH_KIND value)

The default search order is: WebView2 Runtime -> Beta -> Dev -> Canary. Set ChannelSearchKind to COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE to reverse the search order so that environment creation searches for a channel from least to most stable. If ReleaseChannels has been provided, the loader will only search for channels in the set. See COREWEBVIEW2_RELEASE_CHANNELS for more details on channels.

This property can be overridden by the corresponding registry key ChannelSearchKind or the environment variable WEBVIEW2_CHANNEL_SEARCH_KIND. Set the value to 1 to set the search kind to COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE. See CreateCoreWebView2EnvironmentWithOptions for more details on overrides.

put_ReleaseChannels

Sets the ReleaseChannels, which is a mask of one or more COREWEBVIEW2_RELEASE_CHANNELS indicating which channels environment creation should search for.

public HRESULT put_ReleaseChannels(COREWEBVIEW2_RELEASE_CHANNELS value)

OR operation(s) can be applied to multiple COREWEBVIEW2_RELEASE_CHANNELS to create a mask. The default value is a mask of all the channels. By default, environment creation searches for channels from most to least stable, using the first channel found on the device. When ReleaseChannels is provided, environment creation will only search for the channels specified in the set. Set ChannelSearchKind to COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE to reverse the search order so environment creation searches for least stable build first. See COREWEBVIEW2_RELEASE_CHANNELS for descriptions of each channel.

CreateCoreWebView2EnvironmentWithOptions fails with HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) if environment creation is unable to find any channel from the ReleaseChannels installed on the device. Use GetAvailableCoreWebView2BrowserVersionStringWithOptions on ICoreWebView2Environment to verify which channel is used when this option is set.

Examples:

ReleaseChannels Channel Search Kind: Most Stable (default) Channel Search Kind: Least Stable
COREWEBVIEW2_RELEASE_CHANNELS_BETA | COREWEBVIEW2_RELEASE_CHANNELS_STABLE WebView2 Runtime -> Beta Beta -> WebView2 Runtime
COREWEBVIEW2_RELEASE_CHANNELS_CANARY | COREWEBVIEW2_RELEASE_CHANNELS_DEV | COREWEBVIEW2_RELEASE_CHANNELS_BETA | COREWEBVIEW2_RELEASE_CHANNELS_STABLE WebView2 Runtime -> Beta -> Dev -> Canary Canary -> Dev -> Beta -> WebView2 Runtime
COREWEBVIEW2_RELEASE_CHANNELS_CANARY Canary Canary
COREWEBVIEW2_RELEASE_CHANNELS_BETA | COREWEBVIEW2_RELEASE_CHANNELS_CANARY | COREWEBVIEW2_RELEASE_CHANNELS_STABLE WebView2 Runtime -> Beta -> Canary Canary -> Beta -> WebView2 Runtime

If both BrowserExecutableFolder and ReleaseChannels are provided, the BrowserExecutableFolder takes precedence, regardless of whether or not the channel of BrowserExecutableFolder is included in the ReleaseChannels. ReleaseChannels can be overridden by the corresponding registry override ReleaseChannels or the environment variable WEBVIEW2_RELEASE_CHANNELS. Set the value to a comma-separated string of integers, which map to the following release channel values: Stable (0), Beta (1), Dev (2), and Canary (3). For example, the values "0,2" and "2,0" indicate that environment creation should only search for Dev channel and the WebView2 Runtime, using the order indicated by ChannelSearchKind. Environment creation attempts to interpret each integer and treats any invalid entry as Stable channel. See CreateCoreWebView2EnvironmentWithOptions for more details on overrides.