Browse Source

Improved Explorer restart

pull/886/head
Valentin Radu 4 years ago
parent
commit
28de475e51
  1. 11
      ExplorerPatcher/GUI.c
  2. 8
      ep_setup/ep_setup.c

11
ExplorerPatcher/GUI.c

@ -771,7 +771,13 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
if (p) *p = 0; if (p) *p = 0;
if (!strncmp(line + 1, "restart", 7)) if (!strncmp(line + 1, "restart", 7))
{ {
if (FindWindowW(L"Shell_TrayWnd", NULL)) HWND hShellTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
if (hShellTrayWnd)
{
WCHAR wszPath[MAX_PATH];
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
INT64 res = -1;
if (!SendMessageTimeoutW(hShellTrayWnd, 1460, 0, 0, SMTO_ABORTIFHUNG, 2000, &res) && res)
{ {
HANDLE hExplorerRestartThread = CreateThread(NULL, 0, BeginExplorerRestart, NULL, 0, NULL); HANDLE hExplorerRestartThread = CreateThread(NULL, 0, BeginExplorerRestart, NULL, 0, NULL);
if (hExplorerRestartThread) if (hExplorerRestartThread)
@ -786,8 +792,6 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
} }
Sleep(100); Sleep(100);
//ZZRestartExplorer(0, 0, 0, 0); //ZZRestartExplorer(0, 0, 0, 0);
WCHAR wszPath[MAX_PATH];
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
GetSystemDirectoryW(wszPath, MAX_PATH); GetSystemDirectoryW(wszPath, MAX_PATH);
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe"); wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
ShellExecuteW( ShellExecuteW(
@ -798,6 +802,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
NULL, NULL,
SW_SHOWMINIMIZED SW_SHOWMINIMIZED
); );
}
GetWindowsDirectoryW(wszPath, MAX_PATH); GetWindowsDirectoryW(wszPath, MAX_PATH);
wcscat_s(wszPath, MAX_PATH, L"\\explorer.exe"); wcscat_s(wszPath, MAX_PATH, L"\\explorer.exe");
Sleep(1000); Sleep(1000);

8
ep_setup/ep_setup.c

@ -438,6 +438,12 @@ int WINAPI wWinMain(
CoUninitialize(); CoUninitialize();
} }
HWND hShellTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
if (hShellTrayWnd)
{
INT res = -1;
if (!SendMessageTimeoutW(hShellTrayWnd, 1460, 0, 0, SMTO_ABORTIFHUNG, 2000, &res) && res)
{
HANDLE hExplorerRestartThread = CreateThread(NULL, 0, BeginExplorerRestart, NULL, 0, NULL); HANDLE hExplorerRestartThread = CreateThread(NULL, 0, BeginExplorerRestart, NULL, 0, NULL);
if (hExplorerRestartThread) if (hExplorerRestartThread)
{ {
@ -469,6 +475,8 @@ int WINAPI wWinMain(
WaitForSingleObject(sei.hProcess, INFINITE); WaitForSingleObject(sei.hProcess, INFINITE);
CloseHandle(sei.hProcess); CloseHandle(sei.hProcess);
} }
}
}
HWND hWnd = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL); HWND hWnd = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL);
if (hWnd) if (hWnd)

Loading…
Cancel
Save