|
4 | 4 | #include <string> |
5 | 5 | #include <wrl.h> |
6 | 6 | #include <wil/com.h> |
| 7 | + |
7 | 8 | #include "WebView2.h" |
| 9 | +#include "WebView2EnvironmentOptions.h" |
8 | 10 |
|
9 | 11 | #include "Utils.h" |
10 | 12 | #include "Config.h" |
@@ -35,14 +37,6 @@ int CALLBACK WinMain( |
35 | 37 | std::string configJsonPath = FolderFromPath(GetModulePath()) + "config.json"; |
36 | 38 | ConfigJson configJson = LoadConfigJson(configJsonPath); |
37 | 39 |
|
38 | | - // The default channel search order is the WebView2 Runtime, Beta, Dev, and Canary (i.e. stable to unstable). |
39 | | - // When preferUnstableCannel is true in config.json, set the environment variable WEBVIEW2_RELEASE_CHANNEL_PREFERENCE |
40 | | - // to 1 which reverses the channel search order. |
41 | | - if (configJson.preferUnstableChannel) |
42 | | - { |
43 | | - SetEnvironmentVariable(L"WEBVIEW2_RELEASE_CHANNEL_PREFERENCE", L"1"); |
44 | | - } |
45 | | - |
46 | 40 | ///////////////////////////////////////////////////// |
47 | 41 | // Register window class |
48 | 42 | WNDCLASSEX wcex; |
@@ -93,7 +87,17 @@ int CALLBACK WinMain( |
93 | 87 |
|
94 | 88 | ///////////////////////////////////////////////////// |
95 | 89 | // Create and initialize WebView2 |
96 | | - CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, nullptr, |
| 90 | + auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>(); |
| 91 | + |
| 92 | + // The default channel search order is the WebView2 Runtime, Beta, Dev, and Canary (i.e. stable to unstable). |
| 93 | + // When preferUnstableCannel is true in config.json, set the ChannelSearchKind option to |
| 94 | + // to COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE which reverses the channel search order. |
| 95 | + if (configJson.preferUnstableChannel) |
| 96 | + { |
| 97 | + options->put_ChannelSearchKind(COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE); |
| 98 | + } |
| 99 | + |
| 100 | + CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, options.Get(), |
97 | 101 | Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>( |
98 | 102 | [hWnd, configJson](HRESULT result, ICoreWebView2Environment* env) -> HRESULT { |
99 | 103 |
|
|
0 commit comments