Skip to content

Loading preference: Machine-User or User-Machine? #7

Description

@stffabi

During porting of the loader to Go for Wails, I've encountered some inconsistency between the implementation and the official documentation.

In the official docs of CreateCoreWebView2EnvironmentWithOptions Microsoft states:

pass a null or empty string to browserExecutableFolder. In this scenario, the API tries to find a compatible version of the WebView2 Runtime that is installed on the user machine (first at the machine level, and then per user) using the selected channel preference.

But currently OpenWebView2Loader first tries to load at user level and then machine level:

for (int i = 0; i < kNumChannels; i++) {
channel =
preference == WebView2ReleaseChannelPreference::kCanary ? 4 - i : i;
GetInstallKeyPathForChannel(channel, &lpSubKey);
if (FindInstalledClientDllForChannel(lpSubKey.String(), false, versionStr,
clientPath)) {
break;
}
if (FindInstalledClientDllForChannel(lpSubKey.String(), true, versionStr,
clientPath)) {
break;

int FindInstalledClientDllForChannel(PCWSTR lpSubKey, bool system,
WString* versionStr, WString* clientPath) {
HKEY phkResult;
DWORD cbPath = MAX_PATH;
UINT32 version[4];
wchar_t path[MAX_PATH];
if (RegOpenKeyExW(system ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, lpSubKey,
0, KEY_READ | KEY_WOW64_32KEY, &phkResult)) {
return false;
}

@jchv do you possibly remember what the behaviour of the original loader was?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions