From d55307b248ebc94ab79ca33fb2ec9edff0275ae9 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 9 Dec 2021 18:16:21 +0200 Subject: [PATCH] Fixed #529 --- ExplorerPatcher/GUI.c | 12 +++++++++++- ep_setup/ep_setup.c | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ExplorerPatcher/GUI.c b/ExplorerPatcher/GUI.c index b887212..86ae354 100644 --- a/ExplorerPatcher/GUI.c +++ b/ExplorerPatcher/GUI.c @@ -769,7 +769,17 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) { if (FindWindowW(L"Shell_TrayWnd", NULL)) { - BeginExplorerRestart(); + HANDLE hExplorerRestartThread = CreateThread(NULL, 0, BeginExplorerRestart, NULL, 0, NULL); + if (hExplorerRestartThread) + { + WaitForSingleObject(hExplorerRestartThread, 2000); + CloseHandle(hExplorerRestartThread); + hExplorerRestartThread = NULL; + } + else + { + BeginExplorerRestart(); + } Sleep(100); //ZZRestartExplorer(0, 0, 0, 0); WCHAR wszPath[MAX_PATH]; diff --git a/ep_setup/ep_setup.c b/ep_setup/ep_setup.c index cbb2599..de393ac 100644 --- a/ep_setup/ep_setup.c +++ b/ep_setup/ep_setup.c @@ -438,7 +438,17 @@ int WINAPI wWinMain( CoUninitialize(); } - BeginExplorerRestart(); + HANDLE hExplorerRestartThread = CreateThread(NULL, 0, BeginExplorerRestart, NULL, 0, NULL); + if (hExplorerRestartThread) + { + WaitForSingleObject(hExplorerRestartThread, 2000); + CloseHandle(hExplorerRestartThread); + hExplorerRestartThread = NULL; + } + else + { + BeginExplorerRestart(); + } Sleep(100); GetSystemDirectoryW(wszPath, MAX_PATH);