Mercurial > dwindows
diff win/edge.cpp @ 2124:f9a2fc59611c
Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
The previous fix only allowed one dwindows application instance access to Edge.
Create a subdirectory under TEMP with the specified or auto-detected ID.
This change made me pull the application ID code out of #ifdef BUILD_TOAST.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 25 Jun 2020 00:38:37 +0000 |
parents | 589896c07c91 |
children | 663467f6eee4 |
line wrap: on
line diff
--- a/win/edge.cpp Thu Jun 25 00:00:48 2020 +0000 +++ b/win/edge.cpp Thu Jun 25 00:38:37 2020 +0000 @@ -30,7 +30,7 @@ { public: LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - BOOL Detect(VOID); + BOOL Detect(LPWSTR AppID); protected: Microsoft::WRL::ComPtr<ICoreWebView2Environment> Env; }; @@ -224,11 +224,14 @@ WebHost->put_IsVisible(TRUE); } -BOOL EdgeBrowser::Detect(VOID) +BOOL EdgeBrowser::Detect(LPWSTR AppID) { - WCHAR tempdir[MAX_PATH+1]; + WCHAR tempdir[MAX_PATH+1] = {0}; GetTempPathW(MAX_PATH, tempdir); + wcscat(tempdir, AppID); + wcscat(tempdir, L"\\"); + CreateDirectoryW(tempdir, NULL); CreateCoreWebView2EnvironmentWithOptions(nullptr, tempdir, nullptr, Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>( @@ -359,12 +362,12 @@ * If we succeed return TRUE and use Edge for HTML windows. * If it fails return FALSE and fall back to using embedded IE. */ - BOOL _dw_edge_detect(VOID) + BOOL _dw_edge_detect(LPWSTR AppID) { DW_EDGE = new EdgeBrowser; if (DW_EDGE) { - BOOL result = DW_EDGE->Detect(); + BOOL result = DW_EDGE->Detect(AppID); if (!result) { delete DW_EDGE;