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) @@ -771,7 +771,13 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
if (p) *p = 0;
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);
if (hExplorerRestartThread)
@ -786,8 +792,6 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) @@ -786,8 +792,6 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
}
Sleep(100);
//ZZRestartExplorer(0, 0, 0, 0);
WCHAR wszPath[MAX_PATH];
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
GetSystemDirectoryW(wszPath, MAX_PATH);
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
ShellExecuteW(
@ -798,6 +802,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) @@ -798,6 +802,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
NULL,
SW_SHOWMINIMIZED
);
}
GetWindowsDirectoryW(wszPath, MAX_PATH);
wcscat_s(wszPath, MAX_PATH, L"\\explorer.exe");
Sleep(1000);

8
ep_setup/ep_setup.c

@ -438,6 +438,12 @@ int WINAPI wWinMain( @@ -438,6 +438,12 @@ int WINAPI wWinMain(
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);
if (hExplorerRestartThread)
{
@ -469,6 +475,8 @@ int WINAPI wWinMain( @@ -469,6 +475,8 @@ int WINAPI wWinMain(
WaitForSingleObject(sei.hProcess, INFINITE);
CloseHandle(sei.hProcess);
}
}
}
HWND hWnd = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL);
if (hWnd)

Loading…
Cancel
Save