From 2a06e2e577401240764f7c92a7d8397192016f8a Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 21 Jun 2021 15:27:14 +1000 Subject: [PATCH] [windows] Change location of application data --- v2/internal/ffenestri/ffenestri_windows.cpp | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/v2/internal/ffenestri/ffenestri_windows.cpp b/v2/internal/ffenestri/ffenestri_windows.cpp index 504000f1..2c53e432 100644 --- a/v2/internal/ffenestri/ffenestri_windows.cpp +++ b/v2/internal/ffenestri/ffenestri_windows.cpp @@ -282,24 +282,20 @@ bool initWebView2(struct Application *app, int debugEnabled, messageCallback cb) 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> wideCharConverter; -// auto exeName = wideCharConverter.from_bytes(currentExeName); -// -// PWSTR path; -// HRESULT appDataResult = SHGetFolderPathAndSubDir(app->window, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, exeName.c_str(), path); -// if ( appDataResult == false ) { -// path = nullptr; -// } -// + char currentExePath[MAX_PATH]; + GetModuleFileNameA(NULL, currentExePath, MAX_PATH); + char *currentExeName = PathFindFileNameA(currentExePath); + + std::wstring_convert> wideCharConverter; + std::wstring userDataFolder = + wideCharConverter.from_bytes(std::getenv("APPDATA")); + std::wstring currentExeNameW = wideCharConverter.from_bytes(currentExeName); ICoreWebView2Controller *controller; ICoreWebView2* webview; HRESULT res = CreateCoreWebView2EnvironmentWithOptions( - nullptr, nullptr, nullptr, + nullptr, (userDataFolder + L"/" + currentExeNameW).c_str(), nullptr, new wv2ComHandler(app, app->window, cb, [&](ICoreWebView2Controller *webviewController) { controller = webviewController;