C++ WebView2代理C++;

C++ WebView2代理C++;,c++,webview2,C++,Webview2,我在GitHub上找到了线程,但代码似乎不是C++: WebView2 _webView2 = new WebView2(); CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions(); // Set a proxy pac for the browser // options.AdditionalBrowserArguments = "--proxy-pac-url=

我在GitHub上找到了线程,但代码似乎不是C++:

WebView2 _webView2 = new WebView2();

CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions();

// Set a proxy pac for the browser   
//      options.AdditionalBrowserArguments = "--proxy-pac-url=http://myproxy.com/my.pac";

// Set the proxy for the browser
options.AdditionalBrowserArguments = "--proxy-server=\"foopy:99\"";

// Create the environment manually
CoreWebView2Environment env = await CoreWebView2Environment.CreateAsync(null, null, options);
await _webView2 .EnsureCoreWebView2Async(env);
所以我唯一的要求是提供一个解决方案,通过C++来建立WebVIEW2代理。
我有
ICoreWebView2
接口,但它没有
EnsureCoreWebView2Async
方法。另一方面,我有
CoreWebView2EnvironmentOptions
class.

autoopt=Microsoft::WRL::Make();
auto opt = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();

opt->put_AdditionalBrowserArguments(L"--proxy-server=\"SERVER\"");

CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, opt.Get(), Microsoft::WRL::Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
[hwnd](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {

...

}).Get());
opt->put\u AdditionalBrowserArguments(L”--代理服务器=\“服务器\”); CreateCoreWebView2EnvironmentWithOptions(nullptr、nullptr、opt.Get()、Microsoft::WRL::Callback( [hwnd](HRESULT结果,ICoreWebView2Environment*env)->HRESULT{ ... }).Get());
而不是
服务器
放入ip地址或其他内容



我测试过,它可以工作,但似乎有一个bug(或功能):您不能创建两个或多个具有不同运行参数的Web视图。

您读过:?它显示了C++@PoulBak的基本用法,显然我已经读过了,但另一篇文章似乎可以帮助meAll
WebView2
实例共享同一个本机浏览器。只需忽略在第二个实例上设置环境。