@@ -11,7 +11,6 @@ const TCHAR g_szClsid[] = TEXT("{55BBF1B8-0D30-4908-BE0C-D576612A0F48}");
1111HINSTANCE g_hinstDll = NULL ;
1212LPWSTR g_versionInfo = NULL ;
1313LONG g_lLocks = 0 ;
14- WCHAR g_pszDataPath[MAX_PATH ];
1514#ifdef _DEBUG
1615HMODULE g_hWebView2Loader = NULL ;
1716LPFNCreateCoreWebView2EnvironmentWithOptions _CreateCoreWebView2EnvironmentWithOptions = NULL ;
@@ -361,53 +360,6 @@ VOID teVariantChangeType(__out VARIANTARG * pvargDest,
361360 }
362361}
363362
364- VOID DeleteDirectoryR (const WCHAR * pszDir)
365- {
366- // Get path to powershell.exe
367- WCHAR szPowershell[1024 ];
368- UINT len = GetSystemDirectory (szPowershell, MAX_PATH );
369- if (len == 0 || len + 40 >= MAX_PATH ) {
370- return ;
371- }
372- lstrcat (szPowershell, L" \\ WindowsPowerShell\\ v1.0\\ powershell.exe" );
373- DWORD attr = GetFileAttributesW (szPowershell);
374- if (attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY )) {
375- return ;
376- }
377- PathQuoteSpaces (szPowershell);
378-
379- // Get the current process ID
380- DWORD pid = GetCurrentProcessId ();
381-
382- // Build PowerShell command:
383- // Wait-Process -Id <PID>; Remove-Item -Recurse -Force "<dir>"
384- WCHAR szCommand[1024 ];
385- swprintf_s (szCommand, _countof (szCommand), L" -Command Wait-Process -Id %u; Remove-Item -Recurse -Force \" %s\" " , pid, pszDir);
386- lstrcat (szPowershell, szCommand);
387-
388- // Setup process startup info
389- STARTUPINFOW si = { sizeof (si) };
390- PROCESS_INFORMATION pi;
391-
392- // Launch PowerShell process hidden
393- BOOL result = CreateProcess (
394- NULL , // Application name (included in command line)
395- szPowershell, // Command line
396- NULL , // Process security
397- NULL , // Thread security
398- FALSE , // Inherit handles
399- CREATE_NO_WINDOW , // Hide console window
400- NULL , // Environment
401- NULL , // Current directory
402- &si, &pi
403- );
404-
405- if (result) {
406- CloseHandle (pi.hProcess );
407- CloseHandle (pi.hThread );
408- }
409- }
410-
411363// Initialize & Finalize
412364BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD dwReason, LPVOID lpReserved)
413365{
@@ -439,7 +391,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD dwReason, LPVOID lpReserved)
439391 ::FreeLibrary (g_hWebView2Loader);
440392 }
441393#endif
442- DeleteDirectoryR (g_pszDataPath);
443394 break ;
444395 }
445396 return TRUE ;
@@ -1124,16 +1075,15 @@ STDMETHODIMP CteBase::DoVerb(LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSit
11241075{
11251076 if (iVerb == OLEIVERB_INPLACEACTIVATE ) {
11261077 m_hwndParent = hwndParent;
1078+ WCHAR pszDataPath[MAX_PATH ];
11271079 WCHAR pszSetting[MAX_PATHEX + 128 ], pszProxyServer[MAX_PATHEX ], pszProxyOverride[MAX_PATHEX ], pszTemp[MAX_PATHEX ];
11281080 lstrcpy (pszSetting, L" --allow-file-access-from-files --disable-gpu --disable-extensions --disable-features=IsolateOrigins,site-per-process --force-device-scale-factor=1" );
1129- GetTempPath (MAX_PATH , g_pszDataPath);
1130- PathAppend (g_pszDataPath, L" tablacus" );
1131-
1132- SYSTEMTIME st;
1133- GetSystemTime (&st);
1134- WCHAR pszX[] = L" 0123456789abcdefghijklmnopqrstuvwxyz" ;
1135- swprintf_s (pszTemp, MAX_PATH , L" wv%02d%c%c%c%c%02d" , st.wYear % 100 , pszX[st.wMonth ], pszX[st.wDay ], pszX[st.wHour ], pszX[st.wMonth ], st.wSecond );
1136- PathAppend (g_pszDataPath, pszTemp);
1081+ GetTempPath (MAX_PATH , pszDataPath);
1082+ PathAppend (pszDataPath, L" tablacus" );
1083+ HDC hdc = GetDC (hwndParent);
1084+ swprintf_s (pszTemp, MAX_PATH , L" wv%d" , GetDeviceCaps (hdc, LOGPIXELSY ));
1085+ ReleaseDC (hwndParent, hdc);
1086+ PathAppend (pszDataPath, pszTemp);
11371087
11381088 pszProxyServer[0 ] = NULL ;
11391089 pszProxyOverride[0 ] = NULL ;
@@ -1163,9 +1113,9 @@ STDMETHODIMP CteBase::DoVerb(LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSit
11631113 }
11641114 options->put_AdditionalBrowserArguments (pszSetting);
11651115#ifdef _DEBUG
1166- _CreateCoreWebView2EnvironmentWithOptions (NULL , g_pszDataPath , options.Get (), this );
1116+ _CreateCoreWebView2EnvironmentWithOptions (NULL , pszDataPath , options.Get (), this );
11671117#else
1168- CreateCoreWebView2EnvironmentWithOptions (NULL , g_pszDataPath , options.Get (), this );
1118+ CreateCoreWebView2EnvironmentWithOptions (NULL , pszDataPath , options.Get (), this );
11691119#endif
11701120 return S_OK ;
11711121 }
0 commit comments