Skip to content

Commit

Permalink
Merge branch 'geaz-hotfix-userFolder'
Browse files Browse the repository at this point in the history
  • Loading branch information
zserge committed Jun 20, 2020
2 parents f05d0d4 + 0434c18 commit 047d561
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions webview.h
Expand Up @@ -738,9 +738,12 @@ using browser_engine = cocoa_wkwebview_engine;

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <Shlwapi.h>
#include <codecvt>

#pragma comment(lib, "user32.lib")
#pragma comment(lib, "Shlwapi.lib")

// EdgeHTML headers and libs
#include <objbase.h>
Expand Down Expand Up @@ -850,9 +853,17 @@ class edge_chromium : public browser {
CoInitializeEx(nullptr, 0);
std::atomic_flag flag = ATOMIC_FLAG_INIT;
flag.test_and_set();


char currentExePath[MAX_PATH];
GetModuleFileNameA(NULL, currentExePath, MAX_PATH);
char* currentExeName = PathFindFileNameA(currentExePath);

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> wideCharConverter;
std::wstring userDataFolder = wideCharConverter.from_bytes(std::getenv("APPDATA"));
std::wstring currentExeNameW = wideCharConverter.from_bytes(currentExeName);

HRESULT res = CreateCoreWebView2EnvironmentWithOptions(
nullptr, nullptr, nullptr,
nullptr, (userDataFolder + L"/" + currentExeNameW).c_str(), nullptr,
new webview2_com_handler(wnd, cb, [&](ICoreWebView2Controller *controller) {
m_controller = controller;
m_controller->get_CoreWebView2(&m_webview);
Expand Down

0 comments on commit 047d561

Please sign in to comment.