Skip to content

How can I adapt this code to use put_ChannelSearchKind instead of a folder when initialising with Win32? #5055

@ajtruckle

Description

@ajtruckle

@ajtruckle You might just need to point your app to use the Canary WebView2 by following steps here. Initialize your webview2 with CoreWebView2EnvironmentOptions.ChannelSearchKind

Originally posted by @pushkin- in #1737

I would like to adapt my code to use this concept. At the moment I have:

void CWebBrowser::InitializeWebView()
{
	CloseWebView();

	CString subFolder = GetInstallPath();
	CString appData = GetUserDataFolder();

	auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
	CHECK_FAILURE(options->put_AdditionalBrowserArguments(L"--allow-file-access-from-files"));

	HRESULT hr = CreateCoreWebView2EnvironmentWithOptions(
		subFolder,
		appData,
		options.Get(),
		Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
			this,
			&CWebBrowser::OnCreateEnvironmentCompleted).Get());

	if (!SUCCEEDED(hr))
	{
		CString text;
		if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
		{
			text = L"Cannot found the WebView2 component.";
		}
		else
		{
			text = L"Cannot create the webview environment.";
		}

		ShowFailure(hr, text);
	}
}

I am not sure how to tweak this to use the put_ChannelSearchKind(COREWEBVIEW2_CHANNEL_SEARCH_KIND value) property instead of the folder.

I want to temporarily set it to COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions